ajmaln / drf-chat Goto Github PK
View Code? Open in Web Editor NEWLive Chat using Django REST Framework
Live Chat using Django REST Framework
Hi,
We have a project that uses this code as a base for instant messaging. We have added to it though so that we can filter messages for profanity and send images. We noticed that when we go to send a message that no database read is required. This causes an issue where profanity isn't filtered and messages are not displayed until the page is refreshed. We were wondering if you knew how to get sending to also require a database read.
Thanks,
Hi, You mention
This app uses memcached to store Users online status, So you will need to install it.
in your readme. Can you please explain how this works? because all I see is you've added memcached as a cache back-end in Settings.py
After login, the chat page is not displaying in its format. Please help.
Thanks
The panel shows Offline even if the other user is online and constantly sending messaging
No way to get it to work. The self.last_seen() method in chat/models.py always returns None. Therefore users are always marked as offline. It seems that
finally:
cache.set('last_seen_%s' % current_user.username, now,
settings.USER_LASTSEEN_TIMEOUT)
in middleware.py never get hit.
After login, the chat page is not displaying in its format. Please help.
Thanks
It is not returning any get or post data.
After I registered, I cannot login with the username and password.
It will be nice to have something that denotes the online status of a user.
I copied your project, pipped the requirements and ran it as is. I made two users. When one user tries to chat with the other (they click on the new user) you get the following error message:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/chat/2/1
Django Version: 2.0
Python Version: 3.6.4
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'widget_tweaks',
'rest_framework',
'chat']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template error:
In template C:\Users\Starlord\Dev\ChatApp2\DRF-Chat\templates\chat\index.html, error at line 0
no such table: chat_message
1 : {% load staticfiles %}
2 : <!DOCTYPE html>
3 : <html>
4 : <head>
5 : <!--Import Google Icon Font-->
6 : <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
7 : <!--Import materialize.css-->
8 : <link type="text/css" rel="stylesheet" href="{% static 'css/materialize.min.css' %}" media="screen,projection"/>
9 : <link type="text/css" rel="stylesheet" href="{% static 'css/style.css' %}" media="screen,projection"/>
10 :
Traceback:
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\utils.py" in _execute
85. return self.cursor.execute(sql, params)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
303. return Database.Cursor.execute(self, query, params)
The above exception (no such table: chat_message) was the direct cause of the following exception:
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\core\handlers\exception.py" in inner
35. response = get_response(request)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\core\handlers\base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\core\handlers\base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Starlord\Dev\ChatApp2\DRF-Chat\chat\views.py" in message_view
96. Message.objects.filter(sender_id=receiver, receiver_id=sender)})
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\shortcuts.py" in render
36. content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\loader.py" in render_to_string
62. return template.render(context, request)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\backends\django.py" in render
61. return self.template.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render
175. return self._render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in _render
167. return self.nodelist.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render
943. bit = node.render_annotated(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render_annotated
910. return self.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\loader_tags.py" in render
155. return compiled_parent._render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in _render
167. return self.nodelist.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render
943. bit = node.render_annotated(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render_annotated
910. return self.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\loader_tags.py" in render
155. return compiled_parent._render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in _render
167. return self.nodelist.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render
943. bit = node.render_annotated(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render_annotated
910. return self.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\loader_tags.py" in render
67. result = block.nodelist.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render
943. bit = node.render_annotated(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render_annotated
910. return self.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\loader_tags.py" in render
67. result = block.nodelist.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render
943. bit = node.render_annotated(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\base.py" in render_annotated
910. return self.render(context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\template\defaulttags.py" in render
168. len_values = len(values)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\models\query.py" in len
254. self._fetch_all()
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\models\query.py" in _fetch_all
1179. self._result_cache = list(self._iterable_class(self))
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\models\query.py" in iter
54. results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
1063. cursor.execute(sql, params)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\utils.py" in execute
100. return super().execute(sql, params)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\utils.py" in execute
68. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\utils.py" in _execute_with_wrappers
77. return executor(sql, params, many, context)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\utils.py" in _execute
85. return self.cursor.execute(sql, params)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\utils.py" in exit
89. raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\utils.py" in _execute
85. return self.cursor.execute(sql, params)
File "C:\Users\Starlord\Dev\ChatApp2\lib\site-packages\django\db\backends\sqlite3\base.py" in execute
303. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /chat/2/1
Exception Value: no such table: chat_message
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.