Django and Oscar

Evaluating Django-Oscar, a F/OSS Shopping Cart

Published 2021-02-11. Last modified 2021-04-06.
Time to read: 8 minutes.

This page is part of the django collection.

I discussed why I decided to check out the django-oscar e-commerce framework in an earlier article. In this article I describe my experience setting up and running django v3.1.6 and django-oscar v3.0 on Ubuntu 20.04 with Python 3.8.6.

BTW, there are two online django-oscar user groups: the Slack channels and the Google Group.

Getting Started

The very first page in the django-oscar documentation describes a sample project called Frobshop. This article describes my experience installing Frobshop.

Frob (Noun) Any small device or object (usually hand-sized) which can be manipulated.

Etymology: It was adopted by the community of computer programmers which grew out of the MIT Tech Model Railroad Club in the 1950s, and allegedly among the oldest existing words in hacker jargon.

I disabled Django Haystack for Frobshop, and I wrote this article to explain why. I also did not install Apache Solr, as explained in this article.

Installing django-oscar

For manageability of Python runtime versions and libraries, a virtual Python environment should be set up. The required virtual environment will house compatible versions of Python, Django, Django-Oscar and all their dependencies. I decided to locate a virtual environment at ~/venv/aw as explained in A Python Virtual Environment For Every Project:

$ newVenv aw
created virtual environment in 528ms
  creator CPython3Posix(dest=/home/mslinn/venv/aw, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/mslinn/.local/share/virtualenv)
    added seed packages: pip==20.1.1, pkg_resources==0.0.0, setuptools==44.0.0, wheel==0.34.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator 
$ use aw
(aw) $

Next, I installed the Python libraries and their dependencies. Django‑oscar installs Django as a dependency. I also specified a few more dependencies that do not automatically get pulled in. Pip‑tools is installed so dependencies can be managed properly. I installed django.db.backends.postgresql because I wanted to use PostgreSQL instead of SQLite.

BTW, django.db.backends.postgresql_psycopg2 was renamed in django 1.9 to django.db.backends.postgresql, and is installed by pip as django‑postgresql.

(aw) $ pip install django-oscar[sorl-thumbnail] \
pip-tools psycopg2-binary pycountry

BTW, the Frobshop instructions say to install Pillow, but that library is already specified as a django-oscar dependency, so there is no need to install it manually.

Now the virtual environment also contains 2 Django executable images:

ls ~/venv/aw/**



Let’s see information about the versions of django and django-oscar that were just installed into the oscar virtual environment:

(aw) $ pip show django django-oscar
Name: Django
Version: 3.1.6
Summary: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Author: Django Software Foundation
License: BSD-3-Clause
Location: /home/mslinn/oscar/lib/python3.8/site-packages
Requires: asgiref, sqlparse, pytz
Required-by: django-treebeard, django-tables2, django-phonenumber-field, django-oscar, django-haystack, django-extra-views
Name: django-oscar
Version: 3.0
Summary: A domain-driven e-commerce framework for Django
Author: David Winterbottom
License: BSD
Location: /home/mslinn/oscar/lib/python3.8/site-packages
Requires: django-haystack, phonenumbers, django-widget-tweaks, django-treebeard, django-extra-views, Babel, purl, factory-boy, django-tables2, django-phonenumber-field, pillow, django

Generating Frobshop

Now it was time to generate the frobshop project from the template:

(aw) $ mkdir $work/django && cd $work/django

(aw) $ django-admin startproject frobshop

(aw) $ cd frobshop

I now had these files and directories:

(aw) $ tree
├── db.sqlite3
├── frobshop
│   ├──
│   ├── __pycache__
│   ├──
│   ├──
│   ├──
│   └──
└── %}

For convenience, I made frobshop’s copy of the Django command-line utility for administrative tasks executable:

(aw) $ chmod a+x

Creating a Git Repository

I checked in the frobshop project into a private git repository of the same name:

(aw) $ git init

(aw) $ hub create -p frobshop

(aw) $ cat > .gitignore <<EOF

(aw) $ git add .

(aw) $ git commit -m -

(aw) $ git push origin master

As I worked through the tutorial I used git commits, branches and tags to insulate me from messing things up while experimenting. Git made it easy to restore the project to previous states, and to see what had changed between commits. My commit script saved a lot of typing.

# Originally written May 9/05 by Mike Slinn

function help {
   echo "Runs git commit without prompting for a message."
   echo "Usage: commit [options] [file...]"
   echo "   Where options are:"
   echo "      -a \"tag message\""
   echo "      -d # enables debug mode"
   echo "      -m \"commit message\""
   echo "Examples:"
   echo "  commit  # The default commit message is just a single dash (-)"
   echo "  commit -m \"This is a commit message\""
   echo "  commit -a 0.1.2"
   exit 1

function isGitProject {
  cd "$( git rev-parse --git-dir )/.."
  [ -d .git ]

BRANCH="$(git rev-parse --abbrev-ref HEAD)"
while getopts "a:dhm:?" opt; do
   case $opt in
       a ) TAG="$OPTARG"
           git tag -a "$TAG" -m "v$TAG"
           git push origin --tags
       d ) set -xv ;;
       m ) MSG="$OPTARG" ;;
       h ) help ;;
       \?) help ;;
shift "$((OPTIND-1))"

for o in "$@"; do
   if [ "$o" == "-m" ]; then unset MSG; fi

if isGitProject; then
  if [ "$@" ]; then
    git add -A "$@"
    git add -A .
  if [ "$MSG" == "" ]; then MSG="-"; fi
  git commit -m "$MSG" "$@" 3>&1 1>&2 2>&3 | sed -e '/^X11/d'  | sed -e '/^Warning:/d'
  git push origin "$BRANCH" --tags 3>&1 1>&2 2>&3 | sed -e '/^X11/d'  | sed -e '/^Warning:/d'
  echo "Error: '$( pwd )' is not a git project"

if [ -f 0 ]; then rm -f 0; fi
(aw) $ commit -h
Runs git commit without prompting for a message.
Usage: commit [options] [file...]
   Where options are:
      -a "tag message"
      -d # enables debug mode
      -m "commit message"
  commit  # The default commit message is just a single dash (-)
  commit -m "This is a commit message"
  commit -a 0.1.2 Help

The script can do many things. Here are its sub-commands:

(aw) $ ./
Type ' help <subcommand>' for help on a specific subcommand.
  Available subcommands:


I found it strange that Frobshop did not provide requirements.txt to install managed dependencies. I created the file within the frobshop directory so I could replicate this installation on other machines:

(aw) $ pip freeze > requirements.txt

The file looked like this:


I think that requirements.txt should have been provided with Frobshop. If it had been provided, all one would have to do to install the proper version of all the Python modules would be to type:

(aw) $ pip install -r requirements.txt

This was a good time to commit my work to the git repository:

(aw) $ commit -m "First cut at dependencies"

Configuring Frobshop

Here is a comprehensive list of all django-oscar settings. This is a list of all django-oscar default values. Maximizing Django Oscar Settings Variables discusses some poorly documented settings.

The Frobshop documentation says to make massive changes to configuration files, without explaining why. No references are given, but I linked to all the documentation I could find. It seems some core apps, essential to proper operation, are undocumented.

Caution: the contents of these files change quite a bit between recent Django versions, so be warned that the config files are tightly bound to the Django version that it was generated for. This means that if you see a solution on StackOverflow to a problem that you currently have, blindly applying that solution may cause more problems instead of fixing them.

Here are the configured files that were altered, including a few changes I found necessary to make things work.

Django settings for frobshop project.

Generated by 'django-admin startproject' using Django 3.1.6.

For more information on this file, see

For the full list of settings and their values, see

from pathlib import Path
from oscar.defaults import *

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production
# See

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'irs@7(qzjki2)gv7%b)zj5$t-6!l^kod0n4+!&hbgcku&b=$iv'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True


# Application definition




    # 3rd-party apps that oscar depends on
    'sorl.thumbnail',   # Default thumbnail backend, can be replaced




ROOT_URLCONF = 'frobshop.urls'

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

WSGI_APPLICATION = 'frobshop.wsgi.application'

# Database

    'default': {
        #'ENGINE': 'django.db.backends.sqlite3',
        #'NAME': BASE_DIR / 'db.sqlite3',

        'ENGINE': 'django.db.backends.postgresql',
        'HOST': 'localhost',
        'NAME': 'frobshop',
        'PASSWORD': 'secret',
        'PORT': '5432',
        'USER': 'postgres',

        'ATOMIC_REQUESTS': True,

# Password validation

        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

    'default': {
         'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
        #'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        #'URL': '',                 # Assuming you created a core named 'tester' as described in installing search engines.
        #'ADMIN_URL': ''
        # ...or for multicore...
        # 'URL': '',

# Internationalization


TIME_ZONE = 'America/New_York'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'

Here is documentation that helps explain what the above application-related settings above pertain to:

Django’s routing table is defined using

frobshop URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    # path('i18n/', include('django.conf.urls.i18n')),
    path('', include(apps.get_app_config('oscar').urls[0])),

Time once again to commit my work:

(aw) $ commit -m "Initial settings."

Installing PostgreSQL

(aw) $ sudo curl | sudo apt-key add

(aw) $ sudo sh -c 'echo "deb$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

(aw) $ yes | sudo apt install postgresql pgadmin4

(aw) $ sudo service postgresql start

(aw) $ sudo -u postgres /usr/bin/psql -h localhost -c "ALTER USER postgres PASSWORD 'whatever';"

Creating the Database

I had previously installed PostgreSQL. I just needed to create an empty database called frobshop. One option for doing that would be to run psql and pass it parameters that indicate the network node and user to connect, then create the database:

(aw) $ /usr/bin/psql -U postgres \
  -h localhost \
  -c 'create database frobshop'

BTW, I had originally followed the Frobshop tutorial's suggestion to use SQLite. I then tried to convert the frobshop SQLite database to PostgreSQL like this, but the conversion failed:

(aw) $ sudo apt install pgloader

(aw) $ PGPASSWORD=secret /bin/createdb -U postgres -h localhost frobshop

(aw) $ PGPASSWORD=secret pgloader -U postgres -h localhost \
  db.sqlite3 postgresql:///frobshop
(aw) $ PGPASSWORD=secret pgloader -U postgres \
load database
  from db.sqlite3
  into postgresql:///frobshop
  with include drop, create tables, create indexes, reset sequences
  set work_mem to '16MB', maintenance_work_mem to '512 MB';

It would make sense to just set up PostgreSQL straight away if you have any desire to understand how django-oscar works.

Since this step did not change any Frobshop files, there was nothing to commit to the git repository.

oscar_populate_countries Help

A django-oscar website will not work until country information is defined. The oscar_populate_countries subcommand of defines countries. Here is the help information for that subcommand:

(aw) $ ./ oscar_populate_countries -h
usage: oscar_populate_countries [-h] [--no-shipping] [--initial-only] [--version] [-v {0,1,2,3}]
                                          [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                                          [--force-color] [--skip-checks]

Populates the list of countries with data from pycountry.

optional arguments:
  -h, --help            show this help message and exit
  --no-shipping         Don<t mark countries for shipping
  --initial-only        Exit quietly without doing anything if countries were already populated.
  --version             show program<s version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g. "myproject.settings.main". If this isn<t provided,
                        the DJANGO_SETTINGS_MODULE environment variable will be used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don<t colorize the command output.
  --force-color         Force colorization of the command output.
  --skip-checks         Skip system checks. 

Alternative Invocation Style

It is also possible to invoke the manage program like this:

(aw) $ python -m manage oscar_populate_countries -h

Defining Countries

I just want to be able to ship to Canada and the USA. Several steps are required to do that:

  1. Invoke oscar_populate_countries with --no-shipping
    (aw) $ ./ oscar_populate_countries --no-shipping
    Successfully added 249 countries. 
  2. You can enable shipping to selected countries two ways:
    1. Command-line instructions:
      (aw) $ psql -c "update address_country set is_shipping_country = 't' where iso_3166_1_a2 in ('CA', 'US');"
    2. Web Admin instructions
      1. Use django-admin (for me that was http://localhost:8001/admin/).
      2. Navigate to the country editor.
      3. Click on Canada.
      4. Enable Is shipping country and press Save.
      5. Click on Countries at the top of the left-hand menu.
      6. Type United States into the text search field, click on United States, enable Is shipping country and press Save.

Since this step did not change any Frobshop files, there was nothing to commit to the git repository. migrate Options

The Frobshop tutorial does not define data migrations very well. This is a gentle introduction to Django migrations. This is the official documentation, and this is information about writing database migrations.

The help for migrate is:

(aw) $ ./ migrate -h
usage: migrate [-h] [--noinput] [--database DATABASE] [--fake] [--fake-initial] [--plan] [--run-syncdb] [--check]
                         [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback]
                         [--no-color] [--force-color] [--skip-checks]
                         [app_label] [migration_name]
Updates database schema. Manages both apps with migrations and those without.
positional arguments: app_label App label of an application to synchronize the state. migration_name Database state will be brought to the state after that migration. Use the name "zero" to unapply all migrations.
optional arguments: -h, --help show this help message and exit --noinput, --no-input Tells Django to NOT prompt the user for input of any kind. --database DATABASE Nominates a database to synchronize. Defaults to the "default" database. --fake Mark migrations as run without actually running them. --fake-initial Detect if tables already exist and fake-apply initial migrations if so. Make sure that the current database schema matches your initial migration before using this flag. Django will only check for an existing table name. --plan Shows a list of the migration actions that will be performed. --run-syncdb Creates tables for apps without migrations. --check Exits with a non-zero status if unapplied migrations exist. --version show program’s version number and exit -v {0,1,2,3}, --verbosity {0,1,2,3} Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output --settings SETTINGS The Python path to a settings module, e.g. "myproject.settings.main". If this isn’t provided, the DJANGO_SETTINGS_MODULE environment variable will be used. --pythonpath PYTHONPATH A directory to add to the Python path, e.g. "/home/djangoprojects/myproject". --traceback Raise on CommandError exceptions --no-color Don’t colorize the command output. --force-color Force colorization of the command output. --skip-checks Skip system checks.

Creating the Database from Migrations

(aw) $ ./ migrate
System check identified some issues:
WARNINGS: catalogue.ProductAttributeValue.value_boolean: (fields.W903) NullBooleanField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0. HINT: Use BooleanField(null=True) instead. Operations to perform: Apply all migrations: address, admin, analytics, auth, basket, catalogue, communication, contenttypes, customer, flatpages, offer, order, partner, payment, reviews, sessions, shipping, sites, thumbnail, voucher, wishlists Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying address.0001_initial... OK Applying address.0002_auto_20150927_1547... OK Applying address.0003_auto_20150927_1551... OK Applying address.0004_auto_20170226_1122... OK Applying address.0005_regenerate_user_address_hashes... OK Applying address.0006_auto_20181115_1953... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying catalogue.0001_initial... OK Applying analytics.0001_initial... OK Applying analytics.0002_auto_20140827_1705... OK Applying analytics.0003_auto_20200801_0817... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying auth.0010_alter_group_name_max_length... OK Applying auth.0011_update_proxy_permissions... OK Applying auth.0012_alter_user_first_name_max_length... OK Applying sites.0001_initial... OK Applying partner.0001_initial... OK Applying customer.0001_initial... OK Applying basket.0001_initial... OK Applying basket.0002_auto_20140827_1705... OK Applying order.0001_initial... OK Applying offer.0001_initial... OK Applying voucher.0001_initial... OK Applying basket.0003_basket_vouchers... OK Applying basket.0004_auto_20141007_2032... OK Applying basket.0005_auto_20150604_1450... OK Applying basket.0006_auto_20160111_1108... OK Applying basket.0007_slugfield_noop... OK Applying basket.0008_auto_20181115_1953... OK Applying basket.0009_line_date_updated... OK Applying catalogue.0002_auto_20150217_1221... OK Applying catalogue.0003_data_migration_slugs... OK Applying catalogue.0004_auto_20150217_1710... OK Applying catalogue.0005_auto_20150604_1450... OK Applying catalogue.0006_auto_20150807_1725... OK Applying catalogue.0007_auto_20151207_1440... OK Applying catalogue.0008_auto_20160304_1652... OK Applying catalogue.0009_slugfield_noop... OK Applying catalogue.0010_auto_20170420_0439... OK Applying catalogue.0011_auto_20170422_1355... OK Applying catalogue.0012_auto_20170609_1902... OK Applying catalogue.0013_auto_20170821_1548... OK Applying catalogue.0014_auto_20181115_1953... OK Applying catalogue.0015_product_is_public... OK Applying catalogue.0016_auto_20190327_0757... OK Applying catalogue.0017_auto_20190816_0938... OK Applying catalogue.0018_auto_20191220_0920... OK Applying catalogue.0019_option_required... OK Applying catalogue.0020_auto_20200801_0817... OK Applying catalogue.0021_auto_20201005_0844... OK Applying order.0002_auto_20141007_2032... OK Applying order.0003_auto_20150113_1629... OK Applying order.0004_auto_20160111_1108... OK Applying order.0005_update_email_length... OK Applying order.0006_orderstatuschange... OK Applying order.0007_auto_20181115_1953... OK Applying customer.0002_auto_20150807_1725... OK Applying customer.0003_update_email_length... OK Applying customer.0004_email_save... OK Applying customer.0005_auto_20181115_1953... OK Applying communication.0001_initial... OK Applying order.0008_auto_20190301_1035... OK Applying communication.0002_reset_table_names... OK Applying communication.0003_remove_notification_category_make_code_uppercase... OK Applying communication.0004_auto_20200801_0817... OK Applying customer.0006_auto_20190430_1736... OK Applying customer.0007_auto_20200801_0817... OK Applying flatpages.0001_initial... OK Applying offer.0002_auto_20151210_1053... OK Applying offer.0003_auto_20161120_1707... OK Applying offer.0004_auto_20170415_1518... OK Applying offer.0005_auto_20170423_1217... OK Applying offer.0006_auto_20170504_0616... OK Applying offer.0007_conditionaloffer_exclusive... OK Applying offer.0008_auto_20181115_1953... OK Applying offer.0009_auto_20200801_0817... OK Applying offer.0010_conditionaloffer_combinations... OK Applying order.0009_surcharge... OK Applying order.0010_auto_20200724_0909... OK Applying order.0011_auto_20200801_0817... OK Applying partner.0002_auto_20141007_2032... OK Applying partner.0003_auto_20150604_1450... OK Applying partner.0004_auto_20160107_1755... OK Applying partner.0005_auto_20181115_1953... OK Applying partner.0006_auto_20200724_0909... OK Applying payment.0001_initial... OK Applying payment.0002_auto_20141007_2032... OK Applying payment.0003_auto_20160323_1520... OK Applying payment.0004_auto_20181115_1953... OK Applying payment.0005_auto_20200801_0817... OK Applying reviews.0001_initial... OK Applying reviews.0002_update_email_length... OK Applying reviews.0003_auto_20160802_1358... OK Applying reviews.0004_auto_20170429_0941... OK Applying sessions.0001_initial... OK Applying shipping.0001_initial... OK Applying shipping.0002_auto_20150604_1450... OK Applying shipping.0003_auto_20181115_1953... OK Applying sites.0002_alter_domain_unique... OK Applying thumbnail.0001_initial... OK Applying voucher.0002_auto_20170418_2132... OK Applying voucher.0003_auto_20171212_0411... OK Applying voucher.0004_auto_20180228_0940... OK Applying voucher.0005_auto_20180402_1425... OK Applying voucher.0006_auto_20180413_0911... OK Applying voucher.0007_auto_20181115_1953... OK Applying voucher.0008_auto_20200801_0817... OK Applying wishlists.0001_initial... OK Applying wishlists.0002_auto_20160111_1108... OK Applying wishlists.0003_auto_20181115_1953... OK

Since this step did not change any Frobshop files, there was nothing to commit to the git repository.

Mysterious Warning from

The following warning appeared every time ran:

Mysterious warning
catalogue.ProductAttributeValue.value_boolean: (fields.W903) NullBooleanField is deprecated.
Support for it (except in historical migrations) will be removed in Django 4.0.
HINT: Use BooleanField(null=True) instead.

Thanks to StackOverflow, I was able to make this django-oscar warning disappear. This is what the offending line looked like (line folded for legibility):

Isolated problem
value_boolean = models.NullBooleanField(_('Boolean'),
  blank=True, db_index=True)

This is what I understood the suggested change to be (line folded for legibility):

Suggested change
value_boolean = models.BooleanField(_('Boolean'),
  blank=True, db_index=True)

Here is the incantation I used, which relies on an environment variable called oscar to point to the Python virtual environment. Line 1043 of was modified, within the definition of a class called AbstractProductAttributeValue.

(aw) $ sed -i 's/models.NullBooleanField/models.BooleanField/' \

Startapp Subcommand

The startapp subcommand of message is:

(aw) $ ./ startapp --help
usage: startapp [-h] [--template TEMPLATE] [--extension EXTENSIONS] [--name FILES] [--version]
                          [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                          name [directory]

Creates a Django app directory structure for the given app name in the current directory or optionally in the given

positional arguments:
  name                  Name of the application or project.
  directory             Optional destination directory

optional arguments:
  -h, --help            show this help message and exit
  --template TEMPLATE   The path or URL to load the template from.
                        The file extension(s) to render (default: "py"). Separate multiple extensions with commas, or
                        use -e multiple times.
  --name FILES, -n FILES
                        The file name(s) to render. Separate multiple file names with commas, or use -n multiple
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided,
                        the DJANGO_SETTINGS_MODULE environment variable will be used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.
  --force-color         Force colorization of the command output.

Adding a New Django App

I added a new Django app called pricing by using the startapp subcommand of

(aw) $ ./ startapp pricing

That created the following directories:

(aw) $ tree pricing
  ├── migrations
  │   └──

Nullable Field Problem

After adding the new Django app called pricing to frobshop, I encountered this error:

(aw) $ ./ makemigrations pricing
You are trying to change the nullable field 'value_boolean' on productattributevalue to non-nullable without a default; we can’t do that (the database needs something to populate existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
 2) Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
 3) Quit, and let me add a default in
Select an option: 

Update: now I would just provide a one-off default, or blow away with a delete SQL query, since the database do not yet contain important information. Instead, I continued to stumble forward:

I cancelled the makemigrations subcommand and changed the definition of the field to allow nulls, so it looked like what was in the django-oscar master branch (line folded for legibility):
value_boolean = models.BooleanField(_('Boolean'), blank=True,
  null=True, db_index=True)

The error went away the next time I ran makemigrations. The sed command to make this change is:

(aw) $ sed -i \
  -e 's/value_boolean = /models.NullBooleanField/models.BooleanField/' \
  -e 's/value_boolean = /)/, null=True)/' \

Creating the Django Superuser

The Frobshop documentation did not mention this topic. It is easy to do.

(aw) $ ./ createsuperuser
Username (leave blank to use 'mslinn'):
Email address:
Password (again):
Superuser created successfully.

Since this step did not change any Frobshop files, there was nothing to commit to the git repository. runserver Options

The help for runserver is:

(aw) $ ./ runserver -h
usage: runserver [-h] [--ipv6] [--nothreading] [--noreload] [--nostatic] [--insecure] [--version] [-v {0,1,2,3}]
                           [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]

Starts a lightweight Web server for development and also serves static files.

positional arguments:
  addrport              Optional port number, or ipaddr:port

optional arguments:
  -h, --help            show this help message and exit
  --ipv6, -6            Tells Django to use an IPv6 address.
  --nothreading         Tells Django to NOT use threading.
  --noreload            Tells Django to NOT use the auto-reloader.
  --nostatic            Tells Django to NOT automatically serve static files at STATIC_URL.
  --insecure            Allows serving static files even if DEBUG is False.
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.
  --force-color         Force colorization of the command output. 

Launching Oscar

Finally it was time to launch oscar on port 8000: BTW, Django forks into 2 processes when it launches, and each process loads the settings separately. Use the --noreload option to force loading the settings only once.

(aw) $ ./ runserver --noreload
Watching for file changes with StatReloader
February 11, 2021 - 15:45:01
Django version 3.1.6, using settings 'frobshop.settings'
Starting development server at
Quit the server with CONTROL-C. 

Launch Failure

Frobshop failed to launch. This was due to a serious django-oscar implementation deficiency:

  1. django-oscar forms is hard-coded to require django-haystack:
    Excerpt from oscar/apps/search/forms.html
    from haystack.forms import FacetedSearchForm
  2. Oscar uses Haystack to abstract away from different search backends. Unfortunately, writing backend-agnostic code is nonetheless hard and Apache Solr is currently the only supported production-grade backend.
    While the django-oscar documentation describes various other fulltext search backends (ElasticSearch, Whoosh, and Xapian), apparently the official position is that they should not be used in production. ... or so the docs say. No-one seems to believe that statement. The documentation contains some strongly expressed views that are not widely held.

I wrote up an article on this issue, and posted to new GitHub discussion that I created for this topic.


There is a django-haystack backend called SimpleEngine that uses ordinary SQL queries instead of fulltext search.

I installed and enabled django-haystack, and configured frobshop/ to use SimpleEngine. The next time I tried to run django-oscar, it presented itself in my browser at http://localhost:8000.

I logged in as the superuser and saw:

Time once again to commit my work:

(aw) $ commit -m "Switched haystack.backends from SolrEngine to SimpleEngine."

Dashboard Navigation

Browsing throught the django-oscar, I stumbled across where the menu structure of the dashboard navigation is defined, in JSON.

Order Pipeline

The Frobshop tutorial does not offer any information about how the order status of line items affects the status of orders. I found How to set up order processing, which addressed the issue. The tutorial should link to that page.

Reading “How to set up order processing”, it seems there is a checkout app and an order app. A link to these from the article “How to set up order processing” would have been helpful. This page would be a good place to provide a discussion of how apps work together to enable django-oscar’s functionality, but I could only find a generic explanation of Django apps in the Django documentation.

Unfortunately, “How to set up order processing” does not provide a sufficiently detailed explanation to understand the suggested settings in the Frobshop tutorial, which are:

    'Pending': ('Being processed', 'Cancelled',),
    'Being processed': ('Processed', 'Cancelled',),
    'Cancelled': (),

Reading the Frobshop tutorial, I expected that if I copied the above settings into frobshop/ that “With these three settings defined in your project you’ll be able to see the different statuses in the order management dashboard.” However, the information presented in “How to set up order processing” made me think that some custom programming would be required. This Frobshop tutorial is horrible!

I pasted the above into frobshop/, and django-oscar started without errors or warnings. I am unsure how to ‘order’ a product from this tutorial, however.

Time once again to commit my work:

(aw) $ commit -m "Defined order pipeline without understanding what I did."

More Clues

The django-oscar docs are sorely lacking for this topic. I found this buried in the source code for django-oscar: “The pipeline defines the statuses that an order or line item can have and what transitions are allowed in any given status. The pipeline is defined as a dictionary where the keys are the available statuses. Allowed transitions are defined as iterable values for the corresponding status.”

Additional settings in the same internal document include:


This defines a mapping of status changes for order lines which cascade from an order status change. For example:

    'Being processed': 'In progress'

With this mapping, when an order has its status set to Being processed, all lines within it have their status set to In progress. In a sense, the status change cascades down to the related objects. Note that this cascade ignores restrictions from the OSCAR_LINE_STATUS_PIPELINE.


Same as OSCAR_ORDER_STATUS_PIPELINE but for lines. Default: {}


Django-oscar seems well-designed, and seems to have all the features that I am looking for. The community is active, responsive and helpful. However, django-oscar, like many open-source products, suffers from poor documentation and has many problems. Nothing is perfect. However, django-oscar seems to be good enough for my needs.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.