Git Product home page Git Product logo

justchat's Introduction

JustDjango

The Definitive Django Learning Platform.

Django Channels Tutorial Series

This tutorial is for how to build a chat application with Django Channels. The tutorial series can be watched here

To run the backend, run:

virtualenv env
source env/bin/activate
pip install -r requirements.txt
python manage.py runserver

To run the frontend:

npm i
npm start

To develop locally:

1. Change the `DEBUG` flag in `src/settings.js`
2. Create two users (easiest way might be to run `python manage.py createsuperuser` twice)
3. Using django admin, create a `Contact` object for each user.
4. Make sure you have an instance of redis running. 

To build for deployment:

npm run build

Please note this is a demo project of the concepts used in building a chat app. It is simply not production ready. For example, when the backend receives a message, it'll broadcast to everyone in the room including the sender. This means when you demo the sender role, be aware you'll see every outbound message duplicated. The project is setup for deployment on Heroku however you'll need to follow tutorials on how to get this up and running


Other places you can find us:

YouTube Twitter

justchat's People

Contributors

dopeboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

justchat's Issues

Duplicate Messages in React

Greetings;

I have just downloaded your project, which is great by the way, and i have noticed an issue;

When you send messages, the show up as duplicates in React Page, and they go away after refresh, is there a possible way to solve this issue ?

Cannot import ASGI_APPLICATION module

raise ImproperlyConfigured("Cannot import ASGI_APPLICATION module %r" % path)
django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'justchat.routing'

Chat application between user and customersCppBuzz | Forum

Hi ,

I want to create a chat application with the help of Django-channels. Here I have two models users and customers.where user has credentials and customers don't have credentials...I want to establish a connection between users and customers

So can I create an application without logging in from the customer side?

django.db.utils.OperationalError: no such table: chat_contact

Hi. I made models.py by watching your video, but I'm not sure how to solve this problem.
First of all, when I access to 127.0.0.1:8000/admin/chat/chat/add,
It shows

django.db.utils.OperationalError: no such table: chat_contact

This is my models.py, and I migrated and deleted this models.py for several times.

from django.contrib.auth import get_user_model
from django.db import models

User = get_user_model()


# Create your models here.
class Contact(models.Model):
    user = models.ForeignKey(User, related_name='friends', on_delete=models.CASCADE)
    friends = models.ManyToManyField('self', blank=True)

    def __str__(self):
        return self.user.username


class Message(models.Model):
    contact = models.ForeignKey(Contact, related_name='messages', on_delete=models.CASCADE)
    content = models.TextField()
    timestamp = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.contact.user.username


class Chat(models.Model):
    participants = models.ManyToManyField(Contact, related_name='chats')
    messages = models.ManyToManyField(Message, blank=True)

    def last_10_messages(self):
        return self.messages.objects.order_by('-timestamp').all()[:10]

    def __str__(self):
        return "{}".format(self.pk)

And this is the Error Occurs.

Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/chat/chat/add/

Django Version: 3.0.4
Python Version: 3.6.5
Installed Applications:
['channels',
'chat',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'corsheaders',
'rest_auth',
'rest_auth.registration',
'rest_framework',
'rest_framework.authtoken']
Installed Middleware:
['corsheaders.middleware.CorsMiddleware',
'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 E:\Django\Django_Channels\New_Channels\lib\site-packages\django\contrib\admin\templates\admin\includes\fieldset.html, error at line 19
no such table: chat_contact
9 : {% for field in line %}
10 : <div{% if not line.fields|length_is:'1' %} class="fieldBox{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}>
11 : {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
12 : {% if field.is_checkbox %}
13 : {{ field.field }}{{ field.label_tag }}
14 : {% else %}
15 : {{ field.label_tag }}
16 : {% if field.is_readonly %}
17 :

{{ field.contents }}

18 : {% else %}
19 : {{ field.field }}
20 : {% endif %}
21 : {% endif %}
22 : {% if field.field.help_text %}
23 :
{{ field.field.help_text|safe }}

24 : {% endif %}
25 :
26 : {% endfor %}
27 :
28 : {% endfor %}
29 :

Traceback (most recent call last):
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\sqlite3\base.py", line 396, in execute
return Database.Cursor.execute(self, query, params)

The above exception (no such table: chat_contact) was the direct cause of the following exception:
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response
response = self.process_exception_by_middleware(e, request)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response
response = response.render()
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\response.py", line 105, in render
self.content = self.rendered_content
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\response.py", line 83, in rendered_content
return template.render(context, self._request)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\backends\django.py", line 61, in render
return self.template.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 171, in render
return self._render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\loader_tags.py", line 62, in render
result = block.nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\loader_tags.py", line 62, in render
result = block.nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\defaulttags.py", line 209, in render
nodelist.append(node.render_annotated(context))
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\loader_tags.py", line 188, in render
return template.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 173, in render
return self._render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\defaulttags.py", line 209, in render
nodelist.append(node.render_annotated(context))
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\defaulttags.py", line 209, in render
nodelist.append(node.render_annotated(context))
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\defaulttags.py", line 309, in render
return nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\defaulttags.py", line 309, in render
return nodelist.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 992, in render
return render_value_in_context(output, context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\template\base.py", line 971, in render_value_in_context
value = str(value)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\utils\html.py", line 373, in
klass.str = lambda self: mark_safe(klass_str(self))
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\boundfield.py", line 33, in str
return self.as_widget()
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\boundfield.py", line 96, in as_widget
renderer=self.form.renderer,
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\widgets.py", line 241, in render
context = self.get_context(name, value, attrs)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\contrib\admin\widgets.py", line 288, in get_context
'rendered_widget': self.widget.render(name, value, attrs),
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\widgets.py", line 241, in render
context = self.get_context(name, value, attrs)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\widgets.py", line 678, in get_context
context = super().get_context(name, value, attrs)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\widgets.py", line 639, in get_context
context['widget']['optgroups'] = self.optgroups(name, context['widget']['value'], attrs)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\widgets.py", line 587, in optgroups
for index, (option_value, option_label) in enumerate(self.choices):
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\forms\models.py", line 1140, in iter
for obj in queryset:
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\models\query.py", line 346, in _iterator
yield from self._iterable_class(self, chunked_fetch=use_chunked_fetch, chunk_size=chunk_size)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\models\query.py", line 57, in iter
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\models\sql\compiler.py", line 1151, in execute_sql
cursor.execute(sql, params)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "E:\Django\Django_Channels\New_Channels\lib\site-packages\django\db\backends\sqlite3\base.py", line 396, in execute
return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /admin/chat/chat/add/
Exception Value: no such table: chat_contact

image

How should I solve this??

Message not showing

Messages are fetched from api but its not showing in chat-log. the error says can't read message of undefined. In console i can see the outputs in array. but when i map those arrays in renderMessage() the chats are not shown. The timestamp also says invalid format

Chat application between user and customers

Hi ,

I want to create a chat application with the help of Django-channels. Here I have two models users and customers.where user has credentials and customers don't have credentials...I want to establish a connection between users and customers

So can I create an application without logging in from the customer side?

Static files

can you push the main.js and style.css in this tutorials i'm stuck about 2 days in you 2nd video of your tutorials

aioredis doesn't support Python version prior 3.5

When I start to run by creating virtual environment and then
pip install -r requirements.txt
I got error bellow

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting aioredis==1.2.0
  Downloading aioredis-1.2.0.tar.gz (150 kB)
     |████████████████████████████████| 150 kB 19 kB/s 
    ERROR: Command errored out with exit status 1:
     command: /home/vishvajeet/Desktop/Programming/django/environment/justchat-master/env/bin/python2.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-S35mTi/aioredis/setup.py'"'"'; __file__='"'"'/tmp/pip-install-S35mTi/aioredis/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-S35mTi/aioredis/pip-egg-info
         cwd: /tmp/pip-install-S35mTi/aioredis/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-S35mTi/aioredis/setup.py", line 15, in <module>
        raise RuntimeError("aioredis doesn't support Python version prior 3.5")
    RuntimeError: aioredis doesn't support Python version prior 3.5
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
It seems aioredis-1.2.0 does not support new version of python.
If possible then try to upgrade from existing version of 2.2 to 3.0.2

Message port closing before response received

Hi,
I have written all the code and imported the .js, .html, and .css files from the repository. The only thing I havent done is change the WebSocket for a ReconectingWebSocket. I understood that it was an improvement, but since the WebSocket worked before adding all the "html styling", it should work after that as well. Granted I expected it might suffer from disconnects every now and then, but it simply doesn't start. Why is it that it works on the simple html version of rooms.html but once we stylize it, it stops working? I am tryin to understand the bottom of it.

TemplateDoesNotExist at / App is not starting with localhost:8000

python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
March 20, 2019 - 18:46:54
Django version 2.1.5, using settings 'justchat.settings'
Starting ASGI/Channels version 2.1.5 development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
HTTP GET /chat/ 200 [0.05, 127.0.0.1:52236]
HTTP GET /static/rest_framework/css/bootstrap-tweaks.css 200 [0.02, 127.0.0.1:52240]
HTTP GET /static/rest_framework/js/jquery-3.3.1.min.js 200 [0.02, 127.0.0.1:52252]
HTTP GET /static/rest_framework/css/prettify.css 200 [0.02, 127.0.0.1:52244]
HTTP GET /static/rest_framework/css/bootstrap.min.css 200 [0.02, 127.0.0.1:52236]
HTTP GET /static/rest_framework/css/default.css 200 [0.02, 127.0.0.1:52248]
HTTP GET /static/rest_framework/js/ajax-form.js 200 [0.02, 127.0.0.1:52256]
HTTP GET /static/rest_framework/js/bootstrap.min.js 200 [0.01, 127.0.0.1:52244]
HTTP GET /static/rest_framework/js/default.js 200 [0.01, 127.0.0.1:52252]
HTTP GET /static/rest_framework/js/csrf.js 200 [0.01, 127.0.0.1:52240]
HTTP GET /static/rest_framework/js/prettify-min.js 200 [0.01, 127.0.0.1:52248]
HTTP GET /static/rest_framework/img/grid.png 200 [0.00, 127.0.0.1:52248]
Internal Server Error: /favicon.ico
Traceback (most recent call last):
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
response = response.render()
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 81, in rendered_content
template = self.resolve_template(self.template_name)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 63, in resolve_template
return select_template(template, using=self.using)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: index.html
HTTP GET /favicon.ico 500 [0.04, 127.0.0.1:52248]
HTTP GET /chat/ 200 [0.05, 127.0.0.1:52248]
Internal Server Error: /favicon.ico
Traceback (most recent call last):
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
response = response.render()
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 81, in rendered_content
template = self.resolve_template(self.template_name)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 63, in resolve_template
return select_template(template, using=self.using)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: index.html
HTTP GET /favicon.ico 500 [0.04, 127.0.0.1:52248]
HTTP GET /api-auth/login/?next=/chat/ 200 [0.03, 127.0.0.1:52248]
Internal Server Error: /favicon.ico
Traceback (most recent call last):
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
response = response.render()
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 81, in rendered_content
template = self.resolve_template(self.template_name)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/response.py", line 63, in resolve_template
return select_template(template, using=self.using)
File "/home/rajesh/justchat/env/lib/python3.6/site-packages/django/template/loader.py", line 47, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: index.html
HTTP GET /favicon.ico 500 [0.04, 127.0.0.1:52248]

page refresh issue inside chat

When I refresh the page, the room id disappears from url, and showing a blank chat room

image

If i click individual chatroom again, a new connection established, click send message and two messages adding to chat window
image

WebSocket connection failed

when I run frontend and click a chat, and want to send a message it doesn't work, and didn't have history message
then i look my console and find

image
how can i resolve it?

static fiiles

Please add the static files. We are stuck at the 2nd video of your channel.
we would be very happy if you add it..

/usr/lib/python3.6/asyncio/selector_events.py in _sock_connect_cb(self, fut, sock, address) if err != 0: # Jump to any except clause below. raise OSError(err, 'Connect call failed %s' % (address,)) except (BlockingIOError, InterruptedError): # socket is still registered, the callback will be retried later ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 6379)

In [4]: import channels.layers

In [5]: channel_layer = channels.layers.get_channel_layer()

In [6]: from asgiref.sync import async_to_sync

In [7]: async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})

ConnectionRefusedError Traceback (most recent call last)
in
----> 1 async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})

/usr/local/lib/python3.6/dist-packages/asgiref/sync.py in call(self, *args, **kwargs)
114 self.executors.current = old_current_executor
115 # Wait for results from the future.
--> 116 return call_result.result()
117
118 def _run_event_loop(self, loop, coro):

/usr/lib/python3.6/concurrent/futures/_base.py in result(self, timeout)
423 raise CancelledError()
424 elif self._state == FINISHED:
--> 425 return self.__get_result()
426
427 self._condition.wait(timeout)

/usr/lib/python3.6/concurrent/futures/_base.py in __get_result(self)
382 def __get_result(self):
383 if self._exception:
--> 384 raise self._exception
385 else:
386 return self._result

/usr/local/lib/python3.6/dist-packages/asgiref/sync.py in main_wrap(self, args, kwargs, call_result, source_thread, exc_info)
154 result = await self.awaitable(*args, **kwargs)
155 else:
--> 156 result = await self.awaitable(*args, **kwargs)
157 except Exception as e:
158 call_result.set_exception(e)

/usr/local/lib/python3.6/dist-packages/channels_redis/core.py in send(self, channel, message)
291 else:
292 index = next(self._send_index_generator)
--> 293 async with self.connection(index) as connection:
294 # Check the length of the list before send
295 # This can allow the list to leak slightly over capacity, but that's fine.

/usr/local/lib/python3.6/dist-packages/channels_redis/core.py in aenter(self)
818
819 async def aenter(self):
--> 820 self.conn = await self.pool.pop()
821 return self.conn
822

/usr/local/lib/python3.6/dist-packages/channels_redis/core.py in pop(self, loop)
68 conns, loop = self._ensure_loop(loop)
69 if not conns:
---> 70 conns.append(await aioredis.create_redis(**self.host, loop=loop))
71 conn = conns.pop()
72 self.in_use[conn] = loop

/usr/local/lib/python3.6/dist-packages/aioredis/commands/init.py in create_redis(address, db, password, ssl, encoding, commands_factory, parser, timeout, connection_cls, loop)
173 timeout=timeout,
174 connection_cls=connection_cls,
--> 175 loop=loop)
176 return commands_factory(conn)
177

/usr/local/lib/python3.6/dist-packages/aioredis/connection.py in create_connection(address, db, password, ssl, encoding, parser, loop, timeout, connection_cls)
106 reader, writer = await asyncio.wait_for(open_connection(
107 host, port, limit=MAX_CHUNK_SIZE, ssl=ssl, loop=loop),
--> 108 timeout, loop=loop)
109 sock = writer.transport.get_extra_info('socket')
110 if sock is not None:

/usr/lib/python3.6/asyncio/tasks.py in wait_for(fut, timeout, loop)
337
338 if timeout is None:
--> 339 return (yield from fut)
340
341 waiter = loop.create_future()

/usr/local/lib/python3.6/dist-packages/aioredis/stream.py in open_connection(host, port, limit, loop, parser, **kwds)
17 protocol = asyncio.StreamReaderProtocol(reader, loop=loop)
18 transport, _ = await loop.create_connection(
---> 19 lambda: protocol, host, port, **kwds)
20 writer = asyncio.StreamWriter(transport, protocol, reader, loop)
21 return reader, writer

/usr/lib/python3.6/asyncio/base_events.py in create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname)
792 else:
793 if len(exceptions) == 1:
--> 794 raise exceptions[0]
795 else:
796 # If they all have the same str(), raise one.

/usr/lib/python3.6/asyncio/base_events.py in create_connection(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname)
779 if self._debug:
780 logger.debug("connect %r to %r", sock, address)
--> 781 yield from self.sock_connect(sock, address)
782 except OSError as exc:
783 if sock is not None:

/usr/lib/python3.6/asyncio/selector_events.py in sock_connect(self, sock, address)
437 fut = self.create_future()
438 self._sock_connect(fut, sock, address)
--> 439 return (yield from fut)
440
441 def _sock_connect(self, fut, sock, address):

/usr/lib/python3.6/asyncio/selector_events.py in _sock_connect_cb(self, fut, sock, address)
467 if err != 0:
468 # Jump to any except clause below.
--> 469 raise OSError(err, 'Connect call failed %s' % (address,))
470 except (BlockingIOError, InterruptedError):
471 # socket is still registered, the callback will be retried later

ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 6379)

error running the app

Tried to run the code and am getting an error template not found, changed the BASE_DIR in settings.py file from build to public where the index.html template is and when I run the server it just shows the page title 'justchat' nothing else am really stuck please help me

Websocket are not authenticated

As far as I understand, the WebSocket consumer does no authentication. So Any WebSocket connection will be accepted and can send messages, am I right?

So, any middleman with the chatId and username can connect and send messages on behalf of that user.

Can not access the chat page....

Can not access the chat page....whenever I get git clone I can not access the chat only the Django Rest Framework page and not the chat itself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.