Skip to main content
  1. All Posts/

django_ecommerce

eCommerce JavaScript

Django Ecommerce/Market

Django E-commerce is a unique marketplace focused on enabling users to buy/sell products directly or request/send quotes without any complicated or exhaustive process. This is the open-source version of a larger project.

Contents

  1. Features
  2. Installation

    1. Download the project
    2. Set Virtual Environment
    3. Configure .ENV Settings
    4. Async Tasks using Celery and Redis
    5. Debug Toolbar
    6. Migrate Database
    7. Create a superuser
    8. Collect static
  3. Run Development Server
  4. First Run and Initial Data

    1. Admin Section
    2. User Section
  5. Order Process
  6. Credits
  7. Screenshots

Features

  1. User Panel

    1. User Management
      • Sign Up
      • Log In
      • Email Password Reset
      • Email Verification
    2.   <li>
          Dashboard
        </li>
        <li>
          Item <ul dir="auto">
            <li>
              Search (Category / Name)
            </li>
            <li>
              Buy Item
            </li>
            <li>
              Request Quote
            </li>
            <li>
              Orders <ul dir="auto">
                <li>
                  Placed By User
                </li>
                <li>
                  Placed By Customer
                </li>
              </ul>
            </li>
            
            <li>
              Quote <ul dir="auto">
                <li>
                  Placed By User
                </li>
                <li>
                  Placed By Customer
                </li>
                <li>
                  Upload Pdf <ul dir="auto">
                    <li>
                      By Customer <ul dir="auto">
                        <li>
                          Purchase Order
                        </li>
                      </ul>
                    </li>
                    
                    <li>
                      By User/Seller <ul dir="auto">
                        <li>
                          Quote
                        </li>
                        <li>
                          Invoice
                        </li>
                        <li>
                          Delivery Receipt
                        </li>
                      </ul>
                    </li>
                  </ul>
                </li>
              </ul>
            </li>
          </ul>
        </li>
        
        <li>
          Email Notifications: Enabled when <code>EMAIL_SEND = True</code> in <code>settings.py</code>
        </li>
        <li>
          SMS Notifications: Enabled when <code>SMS_SEND = True</code> in <code>settings.py</code>. <a rel="nofollow noopener" target="_blank" href="https://pypi.org/project/pingsms-api/">Pingsms API</a>
        </li>
        <li>
          Multiple Addresses: User addresses. One address can be set as default.
        </li>
        <li>
          Multiple Inventories: Each inventory must have an address.
        </li>
        <li>
          Item Listing: Each item is listed by against an inventory with visibility Public/Private.
        </li>
        <li>
          Shopping Cart <ul dir="auto">
            <li>
              Checkout
            </li>
            <li>
              TODO: Payment
            </li>
          </ul>
        </li>
        
        <li>
          TODO: Chats and Notifications
        </li>
      </ol>
      
    3. Admin Panel

      1. Item Types
      2. Items
      3. Weight Groups
      4. Addresses
      5. Inventories
      6. Listings
      7. Orders
      8. Quotes
      9. Shopping Carts

    Installation

    Download the project

    git clone https://github.com/sa1if3/django_ecommerce

    or
    Download ZIP

    Set Virtual Environment

    Create a Virtual Environment

    virtualenv venv

    Activate Virtual Environment

    source venv/bin/activate

    Download Prerequisites using requirements.txt

    pip install -r requirements.txt

    Deactivate Virtual Environment

    deactivate

    Configure Settings

    Create a .env file in project folder django_ecommerce and provide values for the following variables. In case you are not using Email or SMS. Those fields can be left empty.

    SECRET_KEY=django-insecure-+_vcui795ns-2bl-$n)43ttpt6)s5s^2=t+8z*pv6%cqc*s)0i5
    DB_NAME=
    DB_USER=
    DB_PASSWORD=
    EMAIL_HOST_USER=
    EMAIL_HOST_PASSWORD=
    PINGSMS_API_KEY=
    PINGMS_SINGLE_SMS_TEMPLATE=
    PINGMS_SENDER_ID=

    Async Tasks using Celery and Redis

    Install Redis in Ubuntu 20.04 by following this tutorial
    In settings.py set the following variables. Change according to your use case.

    BROKER_URL = 'redis://localhost:6379'
    CELERY_RESULT_BACKEND = 'redis://localhost:6379'
    CELERY_ACCEPT_CONTENT = ['application/json']
    CELERY_TASK_SERIALIZER = 'json'
    CELERY_RESULT_SERIALIZER = 'json'
    CELERY_TIMEZONE = 'Asia/Kolkata'

    Activate Virtual Environment

    source venv/bin/activate

    Run Celery worker

    celery -A django_ecommerce  worker -l info

    [Note: In production, this command can be put in Supervisor]

    Debug Toolbar

    If you are interested in using the debug toolbar make sure to change your settings.py file with the appropriate IP.

    DEBUG = True
    
    INTERNAL_IPS = [
        # ...
        '127.0.0.1',
        # ...
    ]

    Migrate Database

    The project uses PostgreSQL. Make sure your settings.py is set to correct credential.

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'farmersmarket',
            'USER': 'farmersmarketuser',
            'PASSWORD': 'fkfQbfu6gnhGt',
            'HOST': 'localhost',
            'PORT': '',
        }
    }

    Section A of my tutorial covers the setting up of a server part for Django development.
    Run

    python manage.py makemigrations

    Followed by

    python manage.py migrate

    Create a superuser

    A superuser is required to access the admin panel located at /accounts

    python manage.py createsuperuser

    Collect static

    In case static files don’t run properly simply run

    python manage.py collectstatic

    Run Development Server

    To start the project simply run the server with this command inside the activated virtual environment.

    python manage.py runserver

    First Run and Initial Data

    Admin Section

    Go to http://yourdomain.com/accounts and log in as a superuser. The admin needs to set up some initial data which restricts the user to sell items from the given category only. Enter data in the following order

    1. Create Item Types: Type of item being sold
    2. Create Items: Each Item has an item type
    3. Create Weight Groups: Used during the listing, quote request and orders

    User Section

    A seller also needs to set up some initial data to list their items.

    1. Create Address: Used for Inventory and invoices
    2. Create Inventory: Used for Listing items. The name is shown to the buyer too.
    3. Create Listing: List items for personal use view status as Private or public to view and purchase by setting the view status as Public. If all the items of a listing were sold off; the listing becomes automatically private and the seller is notified via email. The seller cannot search for their listings.

    Order Process

    Buy/Sell

    1. Search
    2. Add to Cart
    3. Check Out
    4. View Order Invoice

    Quotes

    1. Search
    2. Request Quote
    3. Seller Uploads Quote
    4. Buyer Uploads Purchase Order
    5. Seller Uploads Invoice and Delivery Receipt

    Credits

    AdminLTE
    unDraw
    pixabay

    Screenshots

    Sign Up
    Email Verification

    Dashboard

    Search

    Log In
    Address

    Checkout
    Inventory