How to Create your own e-commerce shop using Django-Oscar.

Reading Time : ~ .

Oscar is an open-source ecommerce framework for Django. Django Oscar provides a base platform to build an online shop.

Oscar is built as a highly customisable and extendable framework. It supports Pluggable tax calculations, Per-customer pricing, Multi-currency etc.

1. Install Oscar

$ pip install django-oscar

2. Then, create a Django project

$ django-admin.py startproject <project-name>

After creating the project, add all the settings(INSTALLED_APPS, MIDDLEWARE_CLASSES, DATABASES) in your settings file as specified here.

And you can find the reference on how to customize the Django Oscar app, urls, models and views here.

Customising/Overridding templates:

To override Oscar templates, first you need to update the template configuration settings as below in your setting file.

import os

location = lambda x: os.path.join(
    os.path.dirname(os.path.realpath(__file__)), x)

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
    'django.template.loaders.eggs.Loader',

)

from oscar import OSCAR_MAIN_TEMPLATE_DIR

TEMPLATE_DIRS = (
    location('templates'),
    OSCAR_MAIN_TEMPLATE_DIR,
)

Note: In the 'TEMPLATE_DIRS' setting, you have to include your project template directory path first and then comes the Oscar's template folder which you can import from oscar.

By customising templates, you can just replacing all the content with your own content or you can only change blocks using "extends"

Ex: Overriding Home page

{% extends 'oscar/promotions/home.html' %}

{% block content %}
    Content goes here
    ...
    ...
{% endblock content %}
    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
Running Django with PyPy to boost performance Dinesh Deshmukh

Running Django with PyPy to boost performance

Continue Reading...
Autocomplete with Django-Haystack and Elasticsearch with single letter querying. Ashwin Kumar

Django's haystack provides autocomplete functionality. To do autocomplete effectively, the search backend(elasticsearch in this case) uses n-grams (essentially a small window passed over the string). ...

Continue Reading...
Creating Django App Siva Chittamuru

Django is a high-level, free and open-source Python Web framework that encourages rapid development. Django follows the model–view–controller (MVC) architectural pattern. Django's primary goal is ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties