A real-time chat application built with Django.





- Create a superuser(this is the user who will be the customer support).
- Register/Signup another user.
- Login with credentials of the registered user in one window.
- Login with admin credentials in another window.
- Test out the chat functionality.
Make sure you have the following installed:
- Python 3.8+
- pip
- Virtualenv (optional but recommended)
-
Clone the Repository
git clone <repository-url> cd ChatApplication cd ChatApp
-
Create a Virtual Environment
It's recommended to use a virtual environment to manage dependencies.
# On macOS/Linux python3 -m venv venv source venv/bin/activate # On Windows python -m venv venv .\venv\Scripts\activate
-
Install Dependencies
Install the required packages listed in
requirements.txt
.pip install -r requirements.txt
-
Apply Migrations
Run the following commands to set up the database schema:
python manage.py makemigrations python manage.py migrate
-
Create a Superuser
To access the Django admin interface, create a superuser account:
python manage.py createsuperuser
-
Run the Development Server
Start the Django development server to test your app locally.
python manage.py runserver
-
Access the Application
Open your browser and go to:
http://127.0.0.1:8000
-
Database Configuration
This project uses SQLite as the default database for demonstration purposes. SQLite is suitable for local development but not recommended for production.
- For production, consider replacing SQLite with a more robust database, like PostgreSQL or MySQL.
- Update the
DATABASES
setting insettings.py
with your chosen database configuration.
Example configuration for PostgreSQL:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'your_db_name', 'USER': 'your_db_user', 'PASSWORD': 'your_password', 'HOST': 'localhost', 'PORT': '5432', } }
-
Channel Layers Configuration
This project uses Django Channels with an InMemoryChannelLayer for demonstration. The
InMemoryChannelLayer
is a basic in-memory backend useful for development and testing.- For production, use Redis as the channel layer backend, which is more reliable for handling real-time events in a distributed system.
- Update the
CHANNEL_LAYERS
setting insettings.py
:
Example configuration with Redis:
CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [('127.0.0.1', 6379)], }, }, }
This project is licensed under the MIT License.