customize_develop.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. Developing your website
  2. =======================
  3. Page models
  4. -------------
  5. The django app ``website`` has been created with default models based on pre-built abstract
  6. CodeRed CMS models. You can use these as-is, override existing fields and function, and add
  7. custom fields to these models. After making a change to any of these models, be sure to run
  8. ``python manage.py makemigrations`` and ``python manage.py migrate`` to apply the database changes.
  9. Hooks
  10. -----
  11. Building on the concept of wagtail hooks, there are some additional hooks in CodeRed CMS
  12. is_request_cacheable
  13. ^^^^^^^^^^^^^^^^^^^^
  14. This hook is provided by `wagtail-cache <https://github.com/coderedcorp/wagtail-cache>`_.
  15. The callable passed into this hook should take a ``request`` argument, and return a ``bool``
  16. indicating whether or not the response to this request should be cached (served from the cache
  17. if it is already cached). Not returning, or returning anything other than a bool will not
  18. affect the caching decision. For example::
  19. from wagtail.core import hooks
  20. @hooks.register('is_request_cacheable')
  21. def nocache_in_query(request):
  22. # if the querystring contains a "nocache" key, return False to forcibly not cache.
  23. # otherwise, do not return to let the CMS decide how to cache.
  24. if 'nocache' in request.GET:
  25. return False