Skip to content

Customizing Templates and Static Files (incl. JavaScript)

cccs-ip edited this page Oct 6, 2014 · 2 revisions

Django applications allow overriding templates and static files via settings.INSTALLED_APPS (as located within e.g. ~/core/settings/includes/common.py).

To determine exactly what file corresponds to a static file name, it may be necessary to use django shell:

In [1]: from django.contrib.staticfiles import finders

In [2]: finders.find('css/custom.css')
Out[2]: u'/home/paul/wk/cccs/core/theme/static/css/custom.css'

Finding the source template file is a little trickier because there may be more than one. It is best to use the django_debug_toolbar to see what templates have contributed to any given page.

In terms of site design for 'cccs', we are attempting to keep things reasonably simple by defining a 'special' called (theme)[https://github.com/cccs-web/core/tree/master/theme]. This app is used to override the presentation templates and static files supplied by other apps (such as mezzanine) in order customize our theme (hence the name).

To override any static file or template, one must create a corresponding static or template file in the theme app with exactly the same relative path and name (there are plenty of examples there already if this is unclear).

The theme app is really all about front end presentation.

Additional Resources: