2
0

customize_develop.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 website`` and ``python manage.py migrate`` to apply the
  9. database changes.
  10. Hooks
  11. -----
  12. Building on the concept of wagtail hooks, there are some additional hooks in CodeRed CMS
  13. is_request_cacheable
  14. ^^^^^^^^^^^^^^^^^^^^
  15. This hook is provided by `wagtail-cache <https://github.com/coderedcorp/wagtail-cache>`_.
  16. The callable passed into this hook should take a ``request`` argument, and return a ``bool``
  17. indicating whether or not the response to this request should be cached (served from the cache
  18. if it is already cached). Not returning, or returning anything other than a bool will not
  19. affect the caching decision. For example::
  20. from wagtail.core import hooks
  21. @hooks.register('is_request_cacheable')
  22. def nocache_in_query(request, curr_cache_decision):
  23. # if the querystring contains a "nocache" key, return False to forcibly not cache.
  24. # otherwise, do not return to let the CMS decide how to cache.
  25. if 'nocache' in request.GET:
  26. return False
  27. Default Language
  28. ----------------
  29. To adjust the default language of a project, navigate to Project_Name/Project_Name/settings/base.py. Change both the
  30. LANGUAGE_CODE setting and the LANGUAGES setting. For example::
  31. LANGUAGE_CODE = 'es'
  32. LANGUAGES = [
  33. ('es', _('Spanish'))
  34. ]
  35. Note that these settings are both in use to communicate to the users' browser about the default language of the project.
  36. This ensures that users requiring assistive technology have a smooth experience using the site. These settings do not,
  37. on their own, translate or enable multiple languages on the project.
  38. `For a full list of language codes, see this list from W3 Docs. <https://www.w3docs.com/learn-html/html-language-codes.html>`_