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
E-commerce (paypal) integration with Django Ashwin Kumar

E-commerce is integration is becoming almost essential for every web application now a days. There are so many payment gateways to integrate with our application. ...

Continue Reading...
Working with Django Plugins Vinisha Naladala

This blog describes about how to work with django-plugins. Django Plugin is a Simple Plugin Framework for Django. By using django-plugins, you can make your ...

Continue Reading...
Basics of Django templates Siva Chittamuru

Django template engine comes as part of django framework and its very easy, extensible and handy to develop complex web applications with simplest efforts. Lets ...

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