Django Shop is a modern, responsive e-commerce platform built with Django and Bootstrap. It allows users to browse, search for products, manage shopping cart, and make purchases.
- Modern, responsive UI with light/dark mode switcher (Bootstrap 5)
- User authentication, registration, account management, and social login (via
Django Allauth) - Phone number validation (via
Django-PhoneNumberField) - Secure file uploads with validation
- Products:
- Listing, detail pages, and search
- Product ratings and reviews
- Discounts and promotions
- Robust inventory management: stock is atomically decremented on successful payment confirmation
- Shopping cart:
- Persistent carts for guests (session) and authenticated users; automatic merge on login
- Per-item quantity limits (
CART_MAX_ITEM_QTYinsettings.py) - Cart icon in Navbar shows total items (via context processors)
- Order management:
- Decoupled order and payment status for accurate tracking
- Payment via Stripe (powered by
django-payments) - Orders are only marked as paid and processed after Stripe/Admin confirms payment
- Automatic cancellation and error messaging if stock is insufficient at payment time
- User wishlist functionality
- Customer support and contact page
- Career application page
- Advanced address management:
- Multiple addresses per user with exactly one primary (DB-enforced)
- First address auto-set as primary
- Safe primary switching (atomic demotion of previous primary)
- Cannot delete the only remaining address
- Automatic promotion of a new primary after deleting the current one
- Use
pytest,pytest-django, andmodel-bakeryfor fast, expressive tests
Below are screenshots demonstrating some of the key pages and features (image files are in Gallary/):
-
Homepage — Carousel and featured discounts
-
Product detail
-
Cart
-
Sign in — Authentication page with Google option
-
(Recommended) Use a virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Clone the repository:
git clone https://github.com/erfanghorbanee/Django-Shop.git cd Django-Shop -
Install the Python dependencies:
pip install -r requirements/local.txt
-
Apply migrations:
cd Django-Shop python manage.py makemigrations python manage.py migrate -
Create a superuser:
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver
-
Open your browser and go to
http://127.0.0.1:8000.
You can create sample products, categories, and product images using the built-in management command seed_products.
Example usage (from the project root):
python manage.py seed_productsOptions:
--productsN (default:50) — total number of products to create--imagesM (default:2) — number of images to attach per product
Notes:
- The command removes existing
Category,Product, andProductImagerecords before seeding, so use with care. - Product images are fetched from picsum.photos at runtime; an internet connection is required and the
requestspackage must be available.
You can test the payment flow locally with Stripe (using django-payments + Stripe Provider V3).
Prerequisites
- A Stripe account (free).
- Stripe CLI installed.
Install Stripe CLI (macOS):
brew install stripe/stripe-cli/stripeLogin to Stripe from the CLI:
stripe loginExport your Stripe API key (test key) so the app can create sessions/intents:
export STRIPE_API_KEY="sk_test_..."Forward webhooks to Django (required):
stripe listen --forward-to http://127.0.0.1:8000/payments/stripe/webhook/This prints a signing secret like whsec_....
- Easiest path (no signature verification in dev): keep
secure_endpoint: FalseinPAYMENT_VARIANTS(inconfig/settings.py) and just keep the CLI running to forward events. - With signature verification (optional, stricter):
- Add the secret to your environment:
export STRIPE_ENDPOINT_SECRET="whsec_..." - In
config/settings.py, set the Stripe variant with"endpoint_secret": os.getenv("STRIPE_ENDPOINT_SECRET")and"secure_endpoint": True.
- Add the secret to your environment:
Now, run the app and go through checkout.
Test card for a successful payment:
- Number:
4242 4242 4242 4242 - Expiry: any future date (e.g., 12/34)
- CVC: any 3 digits (e.g., 123)
Official references:
To enable users to log in or register using their Google account, follow these steps:
- Go to the Google Cloud Console.
- Create a new project (or select an existing one).
- Navigate to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Set the application type to Web application.
- Add the following to Authorized redirect URIs:
http://127.0.0.1:8000/accounts/google/login/callback/- This is for when we run the app locally.
- Save and copy the Client ID and Client Secret.
In Django-Shop/config/settings.py, update the SOCIALACCOUNT_PROVIDERS section:
SOCIALACCOUNT_PROVIDERS = {
'google': {
'APP': {
'client_id': 'YOUR_GOOGLE_CLIENT_ID',
'secret': 'YOUR_GOOGLE_CLIENT_SECRET',
'key': ''
}
}
}-
Async & Performance
- Add async support for views and background tasks
- Optimize database queries and overall speed
- Implement caching for products, categories, and frequently accessed data
- Move DB to PostgreSQL
-
Admin & Dashboard
- Customize admin dashboard for management
-
Product Discovery & Media
- Add product filters (category, price, rating, etc.)
- Process and optimize images (static and media)
-
Payments & Orders
- Add support for additional payment providers (PayPal, Apple Pay, etc.)
- Improve payment error handling and user feedback
-
User Experience & Security
- Improve security (2FA, rate limiting, etc.)
- Integrate other allauth functionalites (passkeys, etc.)
- Add user notifications (email, in-app) for order/payment status
- Support multiple languages (i18n: Italian, German, ...)
- Optimize for SEO and accessibility
- Separate settings for dev and prod
- Follow cookiecutter practices
- Dockerize the project
- Check Idempotency and where it's needed.
-
Testing & Quality
- Increase test coverage for all core features
- Stress-test server and database under heavy load with concurrent requests
This project is licensed under the GNU General Public License v3.0. See the full text in the LICENSE file.




