A Django-based product catalog and classified ads platform that allows users to create, browse, and manage product listings.
- User authentication (signup, login, logout) via django-allauth
- Create and manage ad listings with images
- Browse ads by category and tags
- Responsive design with Bootstrap 5
- Pagination for ad listings
- Admin interface for content management
- Python 3.11+
- PostgreSQL (recommended) or SQLite
- pip
git clone <repository-url>
cd cadspython3.11 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the project root:
cp .env.example .envEdit .env and set your configuration:
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=postgres://user:password@localhost:5432/cads
For development with SQLite, you can omit DATABASE_URL and it will use SQLite by default.
For PostgreSQL:
createdb cadsRun migrations:
python manage.py migratepython manage.py createsuperuserpython manage.py runserverVisit http://localhost:8000 to see the application.
cads/
├── ads/ # Main application
│ ├── models.py # Data models (Entry, Category, Tag, UserProfile)
│ ├── views.py # View classes
│ ├── forms.py # Form classes
│ ├── urls.py # URL routing
│ ├── admin.py # Admin configuration
│ └── tests.py # Unit tests
├── cads/ # Project configuration
│ ├── settings.py # Django settings
│ ├── urls.py # Root URL configuration
│ └── wsgi.py # WSGI application
├── templates/ # HTML templates
│ ├── base.html # Base template
│ ├── home.html # Homepage
│ ├── ad_new.html # Create ad form
│ ├── entry_detail.html # Ad detail page
│ ├── category_list.html # Category listing
│ └── tag_list.html # Tag listing
├── static/ # Static files (CSS, JS, images)
├── media/ # User-uploaded files
├── requirements.txt # Python dependencies
└── manage.py # Django management script
- Home Page (
/): View all published ads with pagination - Category Page (
/category/<slug>/): View ads filtered by category - Tag Page (
/tag/<slug>/): View ads filtered by tag - Ad Detail (
/entry/<slug>/): View full details of an ad
- Register or login at
/accounts/signup/or/accounts/login/ - Navigate to
/post-ad/ - Fill in the ad details (title, price, description, image)
- Submit the form
Access the admin interface at /admin/ to:
- Manage ads, categories, and tags
- Manage users and profiles
- View and moderate content
python manage.py test adsFor verbose output:
python manage.py test ads -v 2| Variable | Description | Default |
|---|---|---|
SECRET_KEY |
Django secret key | dev key (change in production!) |
DEBUG |
Debug mode | True |
ALLOWED_HOSTS |
Allowed hostnames | localhost,127.0.0.1 |
DATABASE_URL |
Database connection URL | SQLite |
CSRF_TRUSTED_ORIGINS |
CSRF trusted origins | http://localhost:8000 |
The application uses dj-database-url for database configuration. Examples:
- PostgreSQL:
postgres://user:password@localhost:5432/dbname - SQLite:
sqlite:///path/to/db.sqlite3
The project includes a Procfile for Heroku deployment:
heroku create
heroku config:set SECRET_KEY=your-production-secret-key
heroku config:set DEBUG=False
heroku config:set ALLOWED_HOSTS=your-app.herokuapp.com
git push heroku main
heroku run python manage.py migrate
heroku run python manage.py createsuperuser- Set
DEBUG=False - Generate a strong
SECRET_KEY - Configure
ALLOWED_HOSTS - Set up PostgreSQL database
- Configure email backend for production
- Set up static file serving (WhiteNoise is included)
- Enable HTTPS
- Django 5.1 - Web framework
- django-allauth - Authentication
- PostgreSQL/SQLite - Database
- Bootstrap 5 - Frontend framework
- WhiteNoise - Static file serving
- Pillow - Image processing
- Gunicorn - WSGI server
This project is open source.