Customisation: extending templates

Photologue comes with a set of basic templates to get you started quickly - you can of course replace them with your own. That said, it is possible to extend the basic templates in your own project and override various blocks, for example to add css classes. Often this will be enough.

The trick to extending the templates is not special to Photologue, it’s used in other projects such as Oscar.

First, set up your template configuration as so:

# for Django versions < 1.8

from photologue import PHOTOLOGUE_APP_DIR
    ...other template folders...,

# for Django versions >= 1.8
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        # note: if you set APP_DIRS to True, you won't need to add 'loaders' under OPTIONS
        # proceeding as if APP_DIRS is False
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [
                ... context processors ...,
            # start - please add only if APP_DIRS is False
            'loaders': [
            # end - please add only if APP_DIRS is False

The PHOTOLOGUE_APP_DIR points to the directory above Photologue’s normal templates directory. This means that path/to/photologue/template.html can also be reached via templates/path/to/photologue/template.html.

For example, to customise photologue/gallery_list.html, you can have an implementation like:

# Create your own photologue/gallery_list.html
{% extends "templates/photologue/gallery_list.html" %}

... we are now extending the built-in gallery_list.html and we can override
the content blocks that we want to customise ...