Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

how_to_customise_a_view.rst 1.2KB

1234567891011121314151617181920212223242526272829303132
  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.offer.views`` - you can
  13. subclass Oscar's view if you like::
  14. from oscar.apps.offer.views import OfferListView as CoreOfferListView
  15. class OfferListView(CoreOfferListView):
  16. template_name = 'offer/new_list.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_list.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 'offer' app.