Skip to content

ashraful88/cads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CADS - Product Catalog & Ads Platform

A Django-based product catalog and classified ads platform that allows users to create, browse, and manage product listings.

Features

  • 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

Requirements

  • Python 3.11+
  • PostgreSQL (recommended) or SQLite
  • pip

Installation

1. Clone the repository

git clone <repository-url>
cd cads

2. Create and activate a virtual environment

python3.11 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Create a .env file in the project root:

cp .env.example .env

Edit .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.

5. Set up the database

For PostgreSQL:

createdb cads

Run migrations:

python manage.py migrate

6. Create a superuser

python manage.py createsuperuser

7. Run the development server

python manage.py runserver

Visit http://localhost:8000 to see the application.

Project Structure

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

Usage

Browsing Ads

  • 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

Creating Ads

  1. Register or login at /accounts/signup/ or /accounts/login/
  2. Navigate to /post-ad/
  3. Fill in the ad details (title, price, description, image)
  4. Submit the form

Admin Interface

Access the admin interface at /admin/ to:

  • Manage ads, categories, and tags
  • Manage users and profiles
  • View and moderate content

Running Tests

python manage.py test ads

For verbose output:

python manage.py test ads -v 2

Configuration

Environment Variables

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

Database Configuration

The application uses dj-database-url for database configuration. Examples:

  • PostgreSQL: postgres://user:password@localhost:5432/dbname
  • SQLite: sqlite:///path/to/db.sqlite3

Deployment

Heroku

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

Production Checklist

  • 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

Technologies Used

  • 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

License

This project is open source.

About

Python Django based Product Catalog

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors