|
|
@@ -10,13 +10,15 @@ scratch and have decided to use Oscar. Let's call this shop 'frobshop'
|
|
10
|
10
|
You can always review the set-up of the `Sandbox site`_ in case you have
|
|
11
|
11
|
trouble with the below instructions.
|
|
12
|
12
|
|
|
13
|
|
-.. _`Sandbox site`: https://github.com/tangentlabs/django-oscar/tree/releases/0.2/sandbox
|
|
|
13
|
+.. _`Sandbox site`: https://github.com/tangentlabs/django-oscar/tree/master/sites/sandbox
|
|
14
|
14
|
|
|
15
|
15
|
Install by hand
|
|
16
|
16
|
===============
|
|
17
|
17
|
|
|
18
|
18
|
Install Oscar (which will install Django as a dependency), then create the
|
|
19
|
|
-project::
|
|
|
19
|
+project:
|
|
|
20
|
+
|
|
|
21
|
+.. code-block:: bash
|
|
20
|
22
|
|
|
21
|
23
|
pip install django-oscar
|
|
22
|
24
|
django-admin.py startproject frobshop
|
|
|
@@ -27,7 +29,9 @@ Settings
|
|
27
|
29
|
--------
|
|
28
|
30
|
|
|
29
|
31
|
Now edit your settings file ``frobshop.frobshop.settings.py`` to specify a
|
|
30
|
|
-database (we use SQLite for simplicity)::
|
|
|
32
|
+database (we use SQLite for simplicity):
|
|
|
33
|
+
|
|
|
34
|
+.. code-block:: django
|
|
31
|
35
|
|
|
32
|
36
|
DATABASES = {
|
|
33
|
37
|
'default': {
|
|
|
@@ -40,8 +44,13 @@ database (we use SQLite for simplicity)::
|
|
40
|
44
|
}
|
|
41
|
45
|
}
|
|
42
|
46
|
|
|
43
|
|
-Then, add ``oscar.apps.basket.middleware.BasketMiddleware`` to ``MIDDLEWARE_CLASSES``, and
|
|
44
|
|
-set ``TEMPLATE_CONTEXT_PROCESSORS`` to::
|
|
|
47
|
+Then, add ``oscar.apps.basket.middleware.BasketMiddleware`` to
|
|
|
48
|
+``MIDDLEWARE_CLASSES``. It is also recommended to use
|
|
|
49
|
+``django.middleware.transaction.TransactionMiddleware`` too
|
|
|
50
|
+
|
|
|
51
|
+Now set ``TEMPLATE_CONTEXT_PROCESSORS`` to:
|
|
|
52
|
+
|
|
|
53
|
+.. code-block:: django
|
|
45
|
54
|
|
|
46
|
55
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
|
47
|
56
|
"django.contrib.auth.context_processors.auth",
|
|
|
@@ -99,12 +108,16 @@ Now set your auth backends to:
|
|
99
|
108
|
|
|
100
|
109
|
to allow customers to sign in using an email address rather than a username.
|
|
101
|
110
|
|
|
102
|
|
-Modify your ``TEMPLATE_DIRS`` to include the main Oscar template directory::
|
|
|
111
|
+Modify your ``TEMPLATE_DIRS`` to include the main Oscar template directory:
|
|
|
112
|
+
|
|
|
113
|
+.. code-block:: django
|
|
103
|
114
|
|
|
104
|
115
|
from oscar import OSCAR_MAIN_TEMPLATE_DIR
|
|
105
|
116
|
TEMPLATE_DIRS = TEMPLATE_DIRS + (OSCAR_MAIN_TEMPLATE_DIR,)
|
|
106
|
117
|
|
|
107
|
|
-Oscar currently uses Haystack for search so you need to specify::
|
|
|
118
|
+Oscar currently uses Haystack for search so you need to specify:
|
|
|
119
|
+
|
|
|
120
|
+.. code-block:: django
|
|
108
|
121
|
|
|
109
|
122
|
HAYSTACK_CONNECTIONS = {
|
|
110
|
123
|
'default': {
|
|
|
@@ -115,14 +128,18 @@ Oscar currently uses Haystack for search so you need to specify::
|
|
115
|
128
|
When moving towards production, you'll obviously need to switch to a real search
|
|
116
|
129
|
backend.
|
|
117
|
130
|
|
|
118
|
|
-The last addition to the settings file is to import all of Oscar's default settings::
|
|
|
131
|
+The last addition to the settings file is to import all of Oscar's default settings:
|
|
|
132
|
+
|
|
|
133
|
+.. code-block:: django
|
|
119
|
134
|
|
|
120
|
135
|
from oscar.defaults import *
|
|
121
|
136
|
|
|
122
|
137
|
URLs
|
|
123
|
138
|
----
|
|
124
|
139
|
|
|
125
|
|
-Alter your ``frobshop/urls.py`` to include Oscar's URLs::
|
|
|
140
|
+Alter your ``frobshop/urls.py`` to include Oscar's URLs:
|
|
|
141
|
+
|
|
|
142
|
+.. code-block:: django
|
|
126
|
143
|
|
|
127
|
144
|
from django.conf.urls import patterns, include, url
|
|
128
|
145
|
from oscar.app import shop
|
|
|
@@ -134,7 +151,9 @@ Alter your ``frobshop/urls.py`` to include Oscar's URLs::
|
|
134
|
151
|
Database
|
|
135
|
152
|
--------
|
|
136
|
153
|
|
|
137
|
|
-Then create the database and the shop should be browsable::
|
|
|
154
|
+Then create the database and the shop should be browsable:
|
|
|
155
|
+
|
|
|
156
|
+.. code-block:: bash
|
|
138
|
157
|
|
|
139
|
158
|
python manage.py syncdb --noinput
|
|
140
|
159
|
python manage.py migrate
|
|
|
@@ -158,7 +177,9 @@ You also need to specify the initial status for an order and a line item in
|
|
158
|
177
|
respectively.
|
|
159
|
178
|
|
|
160
|
179
|
To give you an idea of what an order pipeline might look like take a look
|
|
161
|
|
-at the Oscar sandbox settings::
|
|
|
180
|
+at the Oscar sandbox settings:
|
|
|
181
|
+
|
|
|
182
|
+.. code-block:: django
|
|
162
|
183
|
|
|
163
|
184
|
OSCAR_INITIAL_ORDER_STATUS = 'Pending'
|
|
164
|
185
|
OSCAR_INITIAL_LINE_STATUS = 'Pending'
|
|
|
@@ -186,7 +207,9 @@ although it is tailored to an agency structure which may not suit everyone.
|
|
186
|
207
|
.. _`template Django project`: https://github.com/tangentlabs/tangent-django-boilerplate
|
|
187
|
208
|
|
|
188
|
209
|
Set up a virtualenv_, and create a new project using the ``startproject``
|
|
189
|
|
-management command::
|
|
|
210
|
+management command:
|
|
|
211
|
+
|
|
|
212
|
+.. code-block:: bash
|
|
190
|
213
|
|
|
191
|
214
|
mkvirtualenv frobshop # using virtualenvwrapper
|
|
192
|
215
|
pip install Django
|
|
|
@@ -219,18 +242,24 @@ follows Tangent's conventions. The structure is::
|
|
219
|
242
|
deploy-to-prod.sh
|
|
220
|
243
|
|
|
221
|
244
|
Replace a few files with Oscar-specific versions (the templated project can be
|
|
222
|
|
-used for non-Oscar projects too)::
|
|
|
245
|
+used for non-Oscar projects too):
|
|
|
246
|
+
|
|
|
247
|
+.. code-block:: bash
|
|
223
|
248
|
|
|
224
|
249
|
mv frobshop/www/urls{_oscar,}.py
|
|
225
|
250
|
mv frobshop/www/deploy/requirements{_oscar,}.txt
|
|
226
|
251
|
mv frobshop/www/conf/default{_oscar,}.py
|
|
227
|
252
|
|
|
228
|
|
-Install dependencies::
|
|
|
253
|
+Install dependencies:
|
|
|
254
|
+
|
|
|
255
|
+.. code-block:: bash
|
|
229
|
256
|
|
|
230
|
257
|
cd frobshop/www
|
|
231
|
258
|
pip install -r deploy/requirements.txt
|
|
232
|
259
|
|
|
233
|
|
-Create database::
|
|
|
260
|
+Create database:
|
|
|
261
|
+
|
|
|
262
|
+.. code-block:: bash
|
|
234
|
263
|
|
|
235
|
264
|
python manage.py syncdb --noinput
|
|
236
|
265
|
python manage.py migrate
|