从单个用户到多个用户Django应用程序 [英] from a single user to multiple users Django app

查看:105
本文介绍了从单个用户到多个用户Django应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个chatbot网络应用程序模拟客户服务,它需要输入,并通过请求/响应和一些后端python文件显示输出。到目前为止,它一次为一个用户工作。现在我想让它在同一时间与多个用户交谈,每个用户都有他/她的聊天页面和cabo​​t应用程序。我发现我应该使用:


  1. Django多会话==>为每个用户创建一个会话。

  2. 子进程==>创建每个用户会话的chatbot应用程序。

知道怎么样?所以,如果这些任何资源的例子如何实现它将是非常有用的。



PS:我在Django开发中使用Django 10.1,Python3和new



谢谢,

解决方案

我不认为您需要使用django-multi-sessions或子进程,您可以利用Django的内置会话框架将chatbot状态与各个会话相关联。如果您有每个用户登录,您还可以使用 django.contrib.auth 将chatbot状态与个人用户相关联。



每个请求/响应周期彼此独立执行。对您的chatbot的工作方式进行一些假设,并且其I / O通过Django:在您的视图中,首先根据会话ID或用户ID获取或初始化适当的chatbot状态,根据该状态处理输入,存储持久性chatbot状态为以下请求/响应周期,并返回响应。



https://docs.djangoproject.com/en/1.11/topics/http/sessions/



https://docs.djangoproject.com/en/1.11/ref / contrib / auth /



http://django-book.readthedocs.io/en/latest/chapter14.html



过滤内容ba在django中对用户进行调整


i have a chatbot web application that simulate a customer service, where it takes the input and shows the output via request/response and some back-end python files.So far it is working for one user at a time. Now i want it to talk to multiple users at the same time where each user has his/her chatting page and cabot application. i found out that i should use:

  1. Django multi-session==> to create a session for each user.
  2. Sub-process==> to create a chatbot app of each user session.

The problem i don't know how?!. So,if these any resource to example on how to implement it that will be very helpful.

PS: i'm using Django 10.1,Python3 and new in the Django development field.

thank you,

解决方案

I don't think you need to use either django-multi-sessions or subprocess, you may be able to leverage Django's built-in sessions framework to associate chatbot state with individual sessions. You could also use django.contrib.auth to associate chatbot state with individual users if you have each user log in. Links below.

Each request/response cycle executes independently of one another. Making some assumptions about how your chatbot works, and that its I/O passes through Django: in your view, first get or initialize the appropriate chatbot state based on the session id or user id, process the input against that state, store the persistent chatbot state for a following request/response cycle, and return the response.

https://docs.djangoproject.com/en/1.11/topics/http/sessions/

https://docs.djangoproject.com/en/1.11/ref/contrib/auth/

http://django-book.readthedocs.io/en/latest/chapter14.html

Filtering content based on users in django

这篇关于从单个用户到多个用户Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆