Starting with Django eCommerce website with django-oscar

Image for post
Image for post

Django is relatively easy framework to learn and can grow on you quickly. Sites like Instagram, Spotify, YouTube, The Washington Post, Bitbucket, Dropbox, Mozilla, Pinterest, Quora, Disqus, NASA Offical Website etc were developed using Django Python Web framework. Source

Django-oscar is a eCommerce framework in django designed to build domain-driven sites means it solves the problem domain of complex eCommerce systems. It is structured in a way that its core functionality can be customized to your needs and it allows a wide range of eCommerce requirements to be handled easily. It solves large scale Business-to-Customer(B2C) to complex Business-to-Business(B2B) sites and gives domain specific business logic and solutions.

Let’s look at its installation so that you can easily start django eCommerce project with django-oscar today.

First of all you need is to create a virtual environment. It can be done without virtual environment but I suggest you to create and let why be question for another day.

py -m venv oscar

py or python3 according to you Python setup. This creates a new environment oscar for your project. And activate your environment with:

On Windows, run:

source oscar/scripts/activate

In Mac or Unix, run:

source oscar/bin/activate 

Now, you need to install django-oscar via python package manager, pip, in virtual environment.

pip install django-oscar
Image for post
Image for post

After django-oscar installed successfully. Now run following command to install django project. Let’s call our project myshop. startproject myshop

Go into the folder where is located. In our case, run:

cd myshop

Now wait and lets edit out file. Paste the following code at the top of file.

from oscar.defaults import *
from oscar import OSCAR_MAIN_TEMPLATE_DIR
from oscar import get_core_apps
# Path helper
location = lambda x: os.path.join(
os.path.dirname(os.path.realpath(__file__)), x)

Now modify your TEMPLATES to include the main Oscar template directory and add the extra context processors. You can replace the whole block into following code.

'DIRS': [
os.path.join(BASE_DIR, 'templates'),
'APP_DIRS': True,
'context_processors': [


Next, modify INSTALLED_APPS add django.contrib.sites, django.contrib.flatpages, and widget_tweaks and append Oscar’s core apps and set SITE_IDto 1 as below:


] + get_core_apps()


Next, Add 'oscar.apps.basket.middleware.BasketMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware' in the MIDDLEWARE


And add the authenciation backends and haystack search for default search as below:

'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',

Now, you can go to terminal with in current directory. And run:

python migrate
python createsuperuser
python runserver

You should see the following:

Image for post
Image for post

Now, go into /admin to enter the admin username, password you set earlier and you will see all the oscar componets ready to roll.

Image for post
Image for post

Okay this is the end. You can now start to playing around with it to create your domain driven beautiful website.

I hope this helps someone. Feel free to clap for appreciation and comment for problems. I will try to help as much as I can.

Thank you. Happy Hacking.

Written by

I design, develop web components and systems and write about them.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store