Django Private Chat2
New and improved https://github.com/Bearle/django-private-chat
Chat app for Django, powered by Django Channels, Websockets & Asyncio
Documentation
The full documentation will be at https://django_private_chat2.readthedocs.io.
Quickstart
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_private_chat2 import urls as django_private_chat2_urls
urlpatterns = [
...
url(r'^', include(django_private_chat2_urls)),
...
]
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.
Support
django_private_chat2
is tested against python3.6, python3.7, python3.8, python3.9 with Django 3.0, Django 3.1 and Django 3.2.
You can view the builds here:
https://travis-ci.com/github/Bearle/django_private_chat2/builds/
Please file an issue if you have any problems with any combination of the above.
Features
Django-related
-
-
-
-
-
-
-
Functionality-related
-
-
-
-
-
-
-
... and more
Example app frontend features
- Auto reconnected websocket
- Toasts about errors & events
- Send text messages
- Search for users
- Create new chat with another user
- Online/offline status
- Realtime messaging via websocket
- Last message
- Auto-avatar (identicon) based on user id
- Connection status display
Typing...
status- Message delivery status (sent, received, waiting, etc.)
- Message history
- Persistent chat list
- Read / unread messages
- Unread messages counters (updates when new messages are received)
- Send file messages (upload them to server)
TODO
Frontend (example app) & backend
- Pagination support on frontend
- For messages
- For dialogs
- Example app only - user list
-
✅ Endpoint -
✅ UI
-
-
✅ New dialog support - Online's fetching on initial load
- Last message
-
✅ In fetch -
✅ In new dialog -
✅ On arriving message
-
-
✅ Read / unread/ unread count - Last seen
- Send photo
-
✅ Send file - Reply to message
- Delete message
- Forward message
- Search for dialog (username)
-
✅ Frontend (local) Server based- won't do, out of the scope of the project
-
-
✅ Fake data generator (to test & bench) - done via factories in tests - Cache dialogs (get_groups_to_add) - ?
- Move views to async views - ?
- Add some sounds
- New message
- New dialog
- Sent message received db_id
- Optimize /messages/ endpoint
-
✅ Some tests - Full test coverage
- Migration from v1 guide
- Documentation
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
Development commands
pip install -r requirements_dev.txt
invoke -l
Credits
Tools used in rendering this package:
Paid support
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