Multi Room Chat
Django Channels Chat Example taken from channels-examples
Installation
Install Redis
sudo apt install redis-server
check redis status
sudo service redis status
use redis cli
redis-cli
Manual installation
Make a new virtualenv for the project, and run::
pip install -r requirements.txt
Then, you'll need Redis running locally; the settings are configured to
point to localhost
, port 6379
, but you can change this in the
CHANNEL_LAYERS
setting in settings.py
.
Finally, run::
python manage.py migrate
python manage.py runserver
Usage
Make yourself a superuser account::
python manage.py createsuperuser
Then, log into http://localhost:8000/admin/ and make a couple of Room objects. Be sure to make one that is set to "staff-only",
Finally, make a second user account in the admin that doesn't have staff privileges. You'll use this to log into the chat in a second window, and to test the authentication on that staff-only room.
Now, open a second window in another browser or in "incognito" mode - you'll be logging in to the same site with two user accounts. Navigate to http://localhost:8000 in both browsers and open the same chatroom.