Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
E-Commerce Website Using Django Framework with Free Code - E-commerce Site

E-Commerce Website Using Django Framework with Free Code

Posted on September 21, 2024January 12, 2026 By Rishabh saini No Comments on E-Commerce Website Using Django Framework with Free Code

Introduction

Creating an e-commerce website involves more than just displaying products online; it requires handling user authentication, managing a shopping cart, processing orders, and maintaining an admin interface for managing products and sales. The Django framework, with its robust architecture and built-in features, is perfect for building such complex applications. In this tutorial, we will guide you step-by-step to build a basic e-commerce website using Django, complete with source code.

Table of Contents

  • Introduction
  • Core Features
  • Technologies Used
  • Setting Up
    • 1. Installing Django
    • 2.Building a New App and Django Project
    • 3. Setting Up the Project Structure
  • Creating Models
  • Setting Up the Admin Dashboard
  • Building Views and Templates
    • 1. Creating Views for Product Listing and Details
    • 2. Designing Templates with Django Template Language
  • Implementing the Shopping Cart
    • 1. Adding Products to the Cart
    • 2. Viewing and Updating the Cart
  • Creating the Checkout Process
  • User Authentication and Profile Management
  • Deploying

Core Features

  • User Authentication: Sign up, login, and logout functionalities for users.
  • Product Catalog and Search: Displaying products with a search function.
  • Shopping Cart: A cart where users can add and review products before purchasing.
  • Checkout Process: Capturing user details and processing orders.
  • Admin Dashboard: Managing products, categories, and orders from the admin panel.

Technologies Used

  • Django: A sophisticated web framework for Python that promotes quick development.
  • HTML/CSS: For creating the front-end structure and styling.
  • SQLite: The default database provided by Django for development purposes.
  • Django Templates: Django’s powerful templating engine for rendering dynamic content.

Setting Up

1. Installing Django

pip install django

2.Building a New App and Django Project

django-admin startproject ecommerce_site
cd ecommerce_site
django-admin startapp shop

3. Setting Up the Project Structure

Your project structure should look like this:

ecommerce_site/
│
├── ecommerce_site/
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   ├── wsgi.py
│
├── shop/
│   ├── migrations/
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── models.py
│   ├── views.py
│   ├── urls.py
│
├── templates/
│   └── shop/
│       ├── base.html
│       ├── product_list.html
│       ├── product_detail.html
│
└── manage.py

Creating Models

In shop/models.py, specify the e-commerce site’s models:

from django.db import models
from django.contrib.auth.models import User

class Category(models.Model):
    name = models.CharField(max_length=100)
    slug = models.SlugField(unique=True)

    def __str__(self):
        return self.name

class Product(models.Model):
    category = models.ForeignKey(Category, related_name='products', on_delete=models.CASCADE)
    name = models.CharField(max_length=200)
    slug = models.SlugField(unique=True)
    description = models.TextField()
    price = models.DecimalField(max_digits=10, decimal_places=2)
    image = models.ImageField(upload_to='products/')

    def __str__(self):
        return self.name

class Order(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    total_price = models.DecimalField(max_digits=10, decimal_places=2)

class OrderItem(models.Model):
    order = models.ForeignKey(Order, related_name='items', on_delete=models.CASCADE)
    product = models.ForeignKey(Product, on_delete=models.CASCADE)
    quantity = models.PositiveIntegerField()

    def __str__(self):
        return f'{self.quantity} of {self.product.name}'

Setting Up the Admin Dashboard

In shop/admin.py, register your models so you can manage them in the Django admin:

from django.contrib import admin
from .models import Category, Product, Order, OrderItem

admin.site.register(Category)
admin.site.register(Product)
admin.site.register(Order)
admin.site.register(OrderItem)

Building Views and Templates

from django.shortcuts import render, get_object_or_404
from .models import Product

def product_list(request):
    products = Product.objects.all()
    return render(request, 'shop/product_list.html', {'products': products})

def product_detail(request, slug):
    product = get_object_or_404(Product, slug=slug)
    return render(request, 'shop/product_detail.html', {'product': product})

1. Creating Views for Product Listing and Details

In shop/views.py, create views for listing products and viewing product details:

2. Designing Templates with Django Template Language

Create product_list.html and product_detail.html in the templates/shop/ directory:

<!-- product_list.html -->
{% extends 'shop/base.html' %}

{% block content %}
<h1>Product List</h1>
<div class="product-grid">
    {% for product in products %}
        <div class="product-card">
            <img src="{{ product.image.url }}" alt="{{ product.name }}">
            <h3>{{ product.name }}</h3>
            <p>${{ product.price }}</p>
            <a href="{% url 'product_detail' product.slug %}">View Details</a>
        </div>
    {% endfor %}
</div>
{% endblock %}
<!-- product_detail.html -->
{% extends 'shop/base.html' %}

{% block content %}
<div class="product-detail">
    <img src="{{ product.image.url }}" alt="{{ product.name }}">
    <h1>{{ product.name }}</h1>
    <p>${{ product.price }}</p>
    <p>{{ product.description }}</p>
    <form method="post">
        {% csrf_token %}
        <button type="submit">Add to Cart</button>
    </form>
</div>
{% endblock %}
https://updategadh.com/code-snippets/online-shopping-system/

Implementing the Shopping Cart

1. Adding Products to the Cart

In shop/views.py, create a view to handle adding products to the shopping cart.

2. Viewing and Updating the Cart

Create a template and view for displaying the cart contents and allowing users to update quantities or remove items.

Creating the Checkout Process

Capture user details and handle order processing. For real payments, you can integrate third-party services like Stripe.

User Authentication and Profile Management

Make advantage of the authentication mechanism that Django has built-in to let users register, log in, and access their profiles, which include their order histories.

Deploying

Prepare the site for production by configuring settings and choosing a hosting service such as Heroku or AWS. Make sure your static and media assets are served correctly and set up a production database (such as PostgreSQL).

  • New Project :-https://www.youtube.com/@Decodeit2
  • PHP PROJECT:- CLICK HERE

e-commerce website with django
django e-commerce
django e-commerce tutorial
e-commerce website using django source code
django e-commerce website source code
e-commerce website with django and python
e commerce website using django
E-Commerce Website Using Django Framework with Source Code
django commerce
e-commerce website django

Post Views: 1,978
code Snippets Tags:django, django ecommerce, django ecommerce tutorial, django ecommerce website, django ecommerce website tutorial, django framework, Django Project, django python, django shopping cart tutorial, django tutorial, django tutorial for beginners, django web framework (software), e-commerce website django, e-commerce website django app, e-commerce website using django, ecommerce django rest framework, ecommerce website with django, Python Django

Post navigation

Previous Post: Loan Management System in PHP & MySQL with Code
Next Post: Create Address Book in Python with Source Code

More Related Articles

Blockchain Security - What is Blockchain Security code Snippets
Basic Snake Game in Python with Source Code - sanke game Basic Snake Game in Python with Source Code code Snippets
Expense Tracker in Python with Source Code - Expense Tracker in Python with Source Code Expense Tracker in Python with Source Code code Snippets

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Supply Chain Management PHP and CSS
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. F1 Race Road Game in Python Free Source Code
  4. Create Address Book in Python with Source Code
  5. Contact Management in Python with Source Code
  6. Movie Management System in Python with Source Code

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,614)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,215)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,867)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme