This repository contains a Django messaging application with a modern interface, custom user model, privacy controls, online status, and read receipts.
The application allows users to create accounts, send direct messages, and control privacy settings for last seen and read receipts.
Key features:
- Custom user model with username based authentication
- User privacy settings for last seen and read receipts
- Online status and last seen display
- Read receipts for sent messages
- Inbox view with conversation list
- Timezone set to Asia/Kolkata
- Admin interface for managing users and messages
accounts/- custom user model, authentication views, forms, and privacy settingsmessaging/- messaging models, views, templates, and utilitiesmessenger/- Django project settings and URL configurationtemplates/- base template shared by appsdb.sqlite3- local SQLite database filerequirements.txt- Python dependencies
Follow these steps to run the project locally.
-
Open a terminal and change to the project directory.
cd /path/to/messaging-system
-
Create a Python virtual environment.
python3 -m venv venv
-
Activate the virtual environment.
source venv/bin/activate
-
Install the required packages.
pip install -r requirements.txt
-
Copy the example environment file or create a new
.envfile with the required settings.SECRET_KEY=your_secret_key_here DEBUG=True ALLOWED_HOSTS=127.0.0.1,localhost
-
Create database migrations and apply them.
python manage.py makemigrations python manage.py migrate
-
Create a superuser account.
python manage.py createsuperuser
-
Run the local development server.
python manage.py runserver
-
Open the site in your browser.
The project is configured with:
TIME_ZONE = 'Asia/Kolkata'LOGIN_URLand authentication middleware enabled- custom privacy middleware to update user last seen on each request
- Start by creating a new Django project with
django-admin startproject. - Create two apps:
accountsandmessaging. - Define a custom user model in
accounts/models.pyand updateAUTH_USER_MODEL. - Add a middleware that updates
last_seenfor authenticated users. - Build forms and views for signup, login, inbox, message threads, and privacy settings.
- Create templates for the base layout, inbox, chat view, signup, login, and privacy settings.
- Add boolean fields to the user model for
show_last_seenandshow_read_receipts. - In the chat view, pass receiver status and privacy settings to the template.
- Use conditional template rendering to show online status, last seen text, and read receipt ticks.
- Test the app manually and with Django test cases.
Use this command to run the test suite.
python manage.py test
- Make sure the virtual environment is active before running commands.
- If you add new fields to models, create and apply migrations.
- Use secure production settings for deployment instead of
DEBUG=True.
Use the admin interface or command line to manage users and messages.