This project is implementation for the following topics related to technologies used with Django
-Implemented Complete Auth Using Django Default Auth Model.
-Implemented Chat App using Django Channels/Redis/Tortoise ORM
Similarly, we can build Chat Groups
-Deployed on Hostinger VPS
Available at: http://django-chat-app-version1.herokuapp.com/
Note: Remmber to access this project at http because websockets are not configured to run over https in this project yet.
admin login details:-- username: admin password: showmecode
Installing Pre requisites
pip install -r requirements.txt
Making Migrations and Migrating them.
python manage.py makemigrations
python manage.py migrate
Creating Super User.
python manage.py createsuperuser
Note: if you try to access chat room with just one user it will be throwing error.So after creating a superuser register from a new user using website and then enter into it. It must have at least two users to chat.
Installing Redis On Local (For ubuntu) for other Os Please refer to their website https://redis.io/
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis
sudo systemctl restart redis.service
to check if its running or not
sudo systemctl status redis
Uncomment Channel Layers Setting for Local Machine on settings.py, line 137 to 144
CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('127.0.0.1', 6379)],
},
},
}
Comment Channel Layers Setting for Heroku on settings.py, line 147 to 154
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [config('REDIS_URL')],
},
},
}
Run Server.
python manage.py runserver
Installing Heroku Cli
checkout: https://devcenter.heroku.com/articles/heroku-cli
Create your account in Heroku.
Inside your project directory
Login Heroku CLI
heroku login
Create Heroku App
heroku create [app_name]
Push Heroku App
git push heroku master
Configure Heroku App Env Variables
heroku config:set GITHUB_USERNAME=joesmith
Install whitenoise
pip install whitenoise
Include it in Middlewares.
MIDDLEWARE = [
# ...
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
# ...
]
Create Procfile and include this code snippet in it.
release: python manage.py migrate
web: daphne djangochatapplication.asgi:application --port $PORT --bind 0.0.0.0 -v2
To run this project, you will need to add the following environment variables to your .env file
SECRET_KEY=
DEBUG=
DB_HOST=
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_PORT=
EMAIL_USER=
EMAIL_PASS=
ALLOWED_HOSTS=
REDIS_URL=