New and improved https://github.com/Bearle/django-private-chat
Chat app for Django, powered by Django Channels, Websockets & Asyncio
The full documentation will be at https://django-private-chat2.readthedocs.io.
Install django_private_chat2:
pip install django_private_chat2
Add it to your INSTALLED_APPS
:
INSTALLED_APPS = (
...
'django_private_chat2.apps.DjangoPrivateChat2Config',
...
)
Add django_private_chat2's URL patterns:
from django.urls import re_path, include
urlpatterns = [
...
re_path(r'', include('django_private_chat2.urls', namespace='django_private_chat2')),
...
]
Add django_private_chat2's websocket URLs to your asgi.py
:
django_asgi_app = get_asgi_application()
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from django_private_chat2 import urls
application = ProtocolTypeRouter({
"http": django_asgi_app,
"websocket": AuthMiddlewareStack(
URLRouter(urls.websocket_urlpatterns)
),
})
Important:
django_private_chat2 doesn't provide any endpoint to fetch users (required to start new chat, for example)
It's up to you to do so. The example app does it in urls.py
so feel free to copy the handler from there if you wish.
It's important for us to have django_private_chat2
thoroughly tested.
Using github actions, we're able to have django_private_chat2
tested against python3.6, python3.7, python3.8, python3.9, python3.10 with Django 3.0, Django 3.1, Django 3.2, Django 4.0
You can view the builds here:
https://github.com/Bearle/django_private_chat2/actions
The builds are composed of officially supported Django & Python combinations.
Please file an issue if you have any problems with any combination of the above.
Django-related
-:white_check_mark: Fully-functional example app
-:white_check_mark: Uses Django admin
-:white_check_mark: Supports pluggable User model (and accounts for non-integer primary keys, too)
-:white_check_mark: Doesn't require Django Rest Framework (views are based off django.views.generic)
-:white_check_mark: Configurable via settings
-:white_check_mark: Fully translatable
-:white_check_mark: Uses Django storage system & FileField for file uploads (swappable)
Functionality-related
-:white_check_mark: Soft deletable messages
-:white_check_mark: Read/unread messages
-:white_check_mark: Random id (send message first, write to database later)
-:white_check_mark: Supports text & file messages
-:white_check_mark: Gracefully handles errors
-:white_check_mark: Support 'typing' statuses
-:white_check_mark: Upload the file first, send the message later (async uploads) - potential for file ref re-use later
... and more
Typing...
statusFrontend (example app) & backend
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
pip install -r requirements_dev.txt
invoke -l
Tools used in rendering this package:
If you wish to have professional help from the authors of django_private_chat2, or simply hire Django experts to solve a particular problem,
please contact us via email tech
at bearle.ru
or Bearle
in telegram