You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

how_to_customise_a_view.rst 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. =================================
  2. How to customise an existing view
  3. =================================
  4. Oscar has many views. This How-to describes how to customise one of them for
  5. your project. It builds upon the steps described in
  6. :doc:`/topics/customisation`. Please read it first and ensure that you've:
  7. * Created a Python module with the the same label
  8. * Added it as Django app to ``INSTALLED_APPS``
  9. * Added a ``models.py`` and ``admin.py``
  10. Example
  11. -------
  12. Create a new homepage view class in ``myproject.promotions.views`` - you can
  13. subclass Oscar's view if you like::
  14. from oscar.apps.promotions.views import HomeView as CoreHomeView
  15. class HomeView(CoreHomeView):
  16. template_name = 'promotions/new-homeview.html'
  17. In this example, we set a new template location but it's possible to customise
  18. the view in any imaginable way.
  19. As long as the view has the same name as the view you're replacing, and is in
  20. an app with the same name, it will get picked up automatically by Oscar.
  21. If you want to change the template, create the alternative template
  22. ``new-homeview.html``. This could either be
  23. in a project-level ``templates`` folder that is added to your ``TEMPLATE_DIRS``
  24. settings, or a app-level ``templates`` folder within your 'promotions' app. For
  25. now, put something simple in there, such as::
  26. <html>
  27. <body>
  28. <p>You have successfully overridden the homepage template.</p>
  29. </body>
  30. </html>