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
Django - Template language Intro Anjaneyulu Batta

We can write the required logics based on programming[python] syntax in models and views but, when we want to write simple logics we should follow ...

Continue Reading...
Django Custom Template Tags And Filters Nikhila Mergu

Django Template Tags are simple Python functions that accept a value, an optional argument, and return a value to be displayed on the page.
First, ...

Continue Reading...
Add captcha to django web page using Python-reCaptcha Divya Sri

Python-reCaptcha is a pythonic and well-documented reCAPTCHA client that supports all the features of the remote API to generate and verify CAPTCHA challenges. To add ...

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