|
|
@@ -77,8 +77,20 @@ The ``models.py`` file should import all models from the oscar app being overrid
|
|
77
|
77
|
# myproject/promotions/models.py
|
|
78
|
78
|
from oscar.apps.promotions.models import *
|
|
79
|
79
|
|
|
80
|
|
-Now replace ``oscar.apps.promotions`` with ``myproject.promotions`` in the ``INSTALLED_APPS``
|
|
81
|
|
-setting in your settings file.
|
|
|
80
|
+Now replace ``oscar.apps.promotions`` with ``myproject.promotions`` in the
|
|
|
81
|
+``INSTALLED_APPS`` setting in your settings file. To do it, you will need to let
|
|
|
82
|
+Oscar know that you're replacing the corresponding core app with yours. You can
|
|
|
83
|
+do that by supplying an extra argument to ``get_core_apps`` function::
|
|
|
84
|
+
|
|
|
85
|
+ # myproject/settings.py
|
|
|
86
|
+
|
|
|
87
|
+ from oscar import get_core_apps
|
|
|
88
|
+ # ...
|
|
|
89
|
+ INSTALLED_APPS = [
|
|
|
90
|
+ ] + get_core_apps(['myproject.promotions'])
|
|
|
91
|
+
|
|
|
92
|
+The ``get_core_apps`` function will replace ``oscar.apps.promotions`` with
|
|
|
93
|
+``myproject.promotions``.
|
|
82
|
94
|
|
|
83
|
95
|
Now create a new homepage view class in ``myproject.promotions.views`` - you can subclass
|
|
84
|
96
|
Oscar's view if you like::
|
|
|
@@ -91,11 +103,22 @@ Oscar's view if you like::
|
|
91
|
103
|
In this example, we set a new template location but it's possible to customise the view
|
|
92
|
104
|
in any imaginable way.
|
|
93
|
105
|
|
|
|
106
|
+Now create the alternative template ``new-homeview.html``. This could either be
|
|
|
107
|
+in a project-level ``templates`` folder that is added to your ``TEMPLATE_DIRS``
|
|
|
108
|
+settings, or a app-level ``templates`` folder within your 'promotions' app. For
|
|
|
109
|
+now, put something simple in there, such as::
|
|
|
110
|
+
|
|
|
111
|
+ <html>
|
|
|
112
|
+ <body>
|
|
|
113
|
+ <p>You have successfully overridden the homepage template.</p>
|
|
|
114
|
+ </body>
|
|
|
115
|
+ </html>
|
|
|
116
|
+
|
|
94
|
117
|
Next, create a new ``app.py`` for your local promotions app which maps your new ``HomeView``
|
|
95
|
118
|
class to the homepage URL::
|
|
96
|
119
|
|
|
97
|
120
|
# myproject/promotions/app.py
|
|
98
|
|
- from oscar.apps.promotions import PromotionsApplication as CorePromotionsApplication
|
|
|
121
|
+ from oscar.apps.promotions.app import PromotionsApplication as CorePromotionsApplication
|
|
99
|
122
|
|
|
100
|
123
|
from myproject.promotions.views import HomeView
|
|
101
|
124
|
|
|
|
@@ -114,6 +137,8 @@ Finally, hook up the new view to the homepage URL::
|
|
114
|
137
|
class BaseApplication(Shop):
|
|
115
|
138
|
promotions_app = promotions_app
|
|
116
|
139
|
|
|
|
140
|
+ application = BaseApplication()
|
|
|
141
|
+
|
|
117
|
142
|
Quite long-winded, but once this step is done, you have lots of freedom to customise
|
|
118
|
143
|
the app in question.
|
|
119
|
144
|
|