From OSCON 2012. This presentation discusses the reasons for writing an e-commerce framework and details a number of techniques for customising Django apps.
Me •David
Winterbottom
/
@codeinthehole •Tangent
Labs,
London •Head
of
E-‐commerce
team •Python
hacker •commandlinefu.com,
django-‐oscar Friday, 20 July 12
Synopsis •Motivation •Oscar
-‐
what
problem
does
it
solve? •Design
decisions
-‐
customisation
techniques •E-‐commerce
tips/advice Friday, 20 July 12
Two
tier
structure •Application
tier
-‐
serves
HTTP
requests •Processing
tier: •Download
and
import
feeds •Data
cleaning
and
processing •Periodic
jobs
for
fulfilment Friday, 20 July 12
Domain
modelling •Implementation
deeply
connected
to
core
business
concepts •“...where
powerful
new
features
unfold
as
corollaries
to
older
features.” Friday, 20 July 12
Recap •Filename
is
the
ID •Use
include-‐path
trick
to
“subclass”
parent
•Use
blocks
to
provide
hook
points •...but,
don’t
go
too
far Friday, 20 July 12
# myproject/basket/models.py from django.db import models from oscar.apps.basket.abstract_models import \ AbstractLine class Line(AbstractLine): cost_centre = models.CharField(max_length=64) from oscar.apps.basket.models import * Friday, 20 July 12
Generic
vs
bespoke •“If
you’re
using
a
framework,
you
aren’t
doing
good
modelling” •Capture
the
domain
correctly
•It’s
ok
to
throw
away
the
framework Friday, 20 July 12
Summary •Django
is
great
for
modelling
complex
domains •Writing
customisable
django
apps
isn’t
easy •Oscar’s
future:
•NoSQL
-‐
no
more
EAV Friday, 20 July 12