A Django-based classified advertisements web application for managing categories, advertisements, advertiser information, images, and user accounts.
Django Ads Website is a web application built with Django for creating and managing classified advertisements.
The project provides a structured backend for:
- User registration and authentication
- Advertisement management
- Hierarchical categories
- Advertisement images
- Advertiser contact information
- Location information
- Advertisement activation/deactivation
- MySQL database integration
The project is designed as an educational and practical Django web application demonstrating how a classified ads platform can be structured using Django's models, forms, views, templates, authentication system, and ORM.
- Custom Django user model
- User registration
- Login and logout
- Authentication-based navigation
- Additional user information such as age
Each advertisement can contain:
- Title
- Description
- Keywords
- Category
- URL
- Advertiser name or company
- Phone number
- Mobile number
- Instagram ID
- WhatsApp number
- State
- City
- Address
- Active/inactive status
- Creation and modification timestamps
The application supports hierarchical categories using a self-referencing category model.
Each category can have:
- Title
- Description
- Parent category
- Child categories
- Related advertisements
Advertisements can have multiple uploaded images.
The application also supports assigning a main image to an advertisement.
Advertisements contain structured location information including:
- State
- City
- Address
This provides a foundation for building location-based advertisement browsing in future versions.
Django-Ads-website/
├── ads/
│ ├── migrations/
│ ├── templates/
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
│
├── config/
│ ├── migrations/
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│
├── core/
│ ├── migrations/
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
│
├── templates/
│ ├── registration/
│ ├── _base.html
│ └── home.html
│
├── manage.py
└── requirements.txt
- Python
- Django 5.0.3
- MySQL
- Django ORM
- Django Authentication
- Django Templates
- HTML
- CSS
Project dependencies are defined in requirements.txt.
The main domain models are:
Represents advertisement categories and supports parent/child relationships.
Represents an individual classified advertisement and contains the main advertisement information, advertiser details, contact information, and location.
Stores images associated with advertisements.
Extends Django's default user model with additional user information.
The project uses environment variables for sensitive configuration values such as:
- Django secret key
- Database name
- Database username
- Database password
This keeps sensitive configuration outside the source code.
Clone the repository:
git clone https://github.com/AliValizade/Django-Ads-website.git
cd Django-Ads-websiteCreate a virtual environment:
python -m venv venvActivate the virtual environment.
venv\Scripts\activatesource venv/bin/activateInstall dependencies:
pip install -r requirements.txtCreate a .env file in the project root and configure the required environment variables:
DJANGO_SECRET_KEY=your-secret-key
DATABASE_NAME=your-database-name
DATABASE_USER=your-database-user
DATABASE_PASSWORD=your-database-passwordConfigure your MySQL server according to your local environment.
Run migrations:
python manage.py migrateCreate an administrator account:
python manage.py createsuperuserpython manage.py runserverThen open:
http://127.0.0.1:8000/
The Django admin interface can be used to manage:
- Users
- Categories
- Advertisements
- Advertisement images
Create a superuser first and then access:
http://127.0.0.1:8000/admin/
This project demonstrates practical Django concepts including:
- Django project structure
- Django applications
- Models and relationships
- Self-referencing foreign keys
- Custom user models
- Model forms
- Class-based views
- Authentication
- Django admin
- File and image uploads
- URL routing
- Templates
- MySQL integration
- Environment-based configuration
- Django ORM
Possible improvements for future versions include:
- Advanced advertisement search
- Filtering by category and location
- Pagination
- User dashboard
- Advertisement creation/editing from the frontend
- Favorites and saved advertisements
- Advertisement expiration
- Advanced image management
- Search by keywords
- REST API
- Better frontend/UI
- Responsive design
- Advertisement statistics
- Moderation workflow
- SEO improvements
This repository represents an educational and practical Django web application and can serve as a foundation for developing a more complete classified advertisements platform.
Ali Valizade
Python Developer | Django | AI, NLP & Automation | University Instructor
GitHub: AliValizade