======================= How to customise a view ======================= Oscar has many views. This How-to describes how to customise one of them for your project. It builds upon the steps described in :doc:`/topics/customisation`. Please read it first and ensure that you've: * Created a Python module with the the same label * Use custom root and local ``app.py`` Example ------- Create a new homepage view class in ``myproject.promotions.views`` - you can subclass Oscar's view if you like:: from oscar.apps.promotions.views import HomeView as CoreHomeView class HomeView(CoreHomeView): template_name = 'promotions/new-homeview.html' In this example, we set a new template location but it's possible to customise the view in any imaginable way. If you want to change the template, create the alternative template ``new-homeview.html``. This could either be in a project-level ``templates`` folder that is added to your ``TEMPLATE_DIRS`` settings, or a app-level ``templates`` folder within your 'promotions' app. For now, put something simple in there, such as::
You have successfully overridden the homepage template.
Now you can hook it up in your local ``app.py``:: # myproject/promotions/app.py from oscar.apps.promotions.app import PromotionsApplication as CorePromotionsApplication from myproject.promotions.views import HomeView class PromotionsApplication(CorePromotionsApplication): home_view = HomeView application = PromotionsApplication()