pypi i django-private-chat


(Deprecated - Please check out Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team

by Bearle

0.3.0 (see all)License:ISCL
Categories:Django Chat
pypi i django-private-chat


😎 django-private-chat 😎

.. image:: :target:

.. image:: :target:

.. image:: :target:

Please also check out our another package

Django one-to-one Websocket-based Asyncio-handled chat, developed by Bearle team

.. image::

Important Notes

This app uses separate management command, run_chat_server for running Websockets in Django context. It is intended to be used with something like Supervisor or Systemd to run asyncio webserver as a separate one from Django. We didn't want our app to be limited to be used together with Django Channels - that's why we did it that way.

You can find an example Systemd config to run it as a service at



The full documentation is (finally) at . You can also check the docstrings & this readme.

Example project

You can check out our example project by cloning the repo and heading into example/ directory. There is a README file for you to check, initial data to check out the chat included.

Customize the templates

How to customize the template? Just copy::


And feel free to edit it as you like! We intentionally left the JS code inside for it to be editable easily.

Exsiting project quickstart

Install django-private-chat::

pip install django-private-chat


python migrate django-private-chat

Note: you can use this package with or without uvloop, just run either

.. code-block:: python

python run_chat_server

or run

.. code-block:: python

python run_chat_server_uvloop

Add it to your INSTALLED_APPS:

.. code-block:: python


Add the server & port for your asyncio server to settings:

.. code-block:: python

CHAT_WS_SERVER_HOST = 'localhost'

It is possible to change messages datetime format using

.. code-block:: python


Add django-private-chat's URL patterns:

.. code-block:: python

from django_private_chat import urls as django_private_chat_urls

urlpatterns = [
    url(r'^', include('django_private_chat.urls')),


.. code-block:: python

{% block extra_js %}{% endblock extra_js %}

to your base template

Now you can start a dialog using ::


To create a WSS (TLS) server instead:

.. code-block:: python

python run_chat_server "path/to/cert.pem"

(also works with uvloop). The "cert.pem" file should be a plaintext PEM file containing first a private key, then a certificate (may be a concatenation of a .key and a .crt file). Please note that wss will use TLSv1 by default for python 3.5 & 3.4 and will use ssl.PROTOCOL_TLS_SERVER for 3.6 and above.


-βœ… Uses current app model (get_user_model() and settings.AUTH_USER_MODEL)

-βœ… Translatable (uses ugettext and {% trans %} )

-βœ… One-to-one user chat

-βœ… Works using WebSockets

-βœ… Works (optionally) using WSS (TLS) connections (disclaimer - security not guaranteed)

-βœ… Displays online/offline status

-βœ… Display typing/not typing status

-βœ… Soft deletable message model - be sure to keep messages to comply with message-keeping laws

-βœ… Flash the dialog button when the user you are not currently talking to wrote you a message

-πŸ‘‰ TODO: add a dialog to the list when new one started

-πŸ‘‰ TODO: add user-not-found and other alerts

-πŸ‘‰ possible Redis backend intergration

Running Tests

Does the code actually work?


source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox


Tools used in rendering this package:

  • Cookiecutter_
  • cookiecutter-djangopackage_

.. Cookiecutter: .. cookiecutter-djangopackage:


0.3.0 (2020-05-03) ++++++++++++++++++

  • Update deps, example to Django 2.2.12
  • Move to async/await syntax

0.2.2 (2018-12-12) ++++++++++++++++++

  • Fix read_message_handler by idonoso

0.2.1 (2018-12-07) ++++++++++++++++++

  • Compatibility with python3.7 by Emeka Icha

0.2.0 (2018-10-22) ++++++++++++++++++

  • Added WSS fix for python 3.4 & 3.5

0.1.9 (2018-07-16) ++++++++++++++++++

  • Added WSS support by @zsmith3

0.1.8 (2018-03-23) ++++++++++++++++++

  • Fixed time in Message model to be timezone-aware

0.1.7 (2018-03-20) ++++++++++++++++++

  • Additions for django 2.0

0.1.6 (2017-04-11) ++++++++++++++++++

  • Fixed bugs with static files and added comment about extra_js block to readme

0.1.5 (2017-03-11) ++++++++++++++++++

  • Added flashing other user button when he sent you a message and you're in another dialog

0.1.4 (2017-02-12) ++++++++++++++++++

  • Added support for django 1.8,1.9

0.1.3 (2017-02-11) ++++++++++++++++++

  • Removed uvloop from requirements

0.1.2 (2017-02-11) ++++++++++++++++++

  • Fixed i18n not loaded in dialogs template bug

0.1.1 (2017-02-10) ++++++++++++++++++

  • Added migrations.

0.1.0 (2017-02-10) ++++++++++++++++++

  • First release on PyPI.