Templates

In django templates can be overwritten and modified by other apps.

Juntagrico provides template snippets or template blocks, that allow you to modify parts of certain templates, e.g., descriptive text or menu entries.

Note

Templates or template blocks that are not documented in this reference may change in future versions without notice. Changing undocumented and will increase your maintenance work.

If you think the changes you want to make could also benefit other juntagrico users, consider opening an issue, suggesting your changes to juntagrico directly. If you need your changes quickly, you may still want to override the templates as described here.

Hint

Some texts, e.g. of forms, do not appear in the template. To change these see below

Set up Template Overrides

The instructions for overriding templates in django can be found in the the official documentation. Roughly these are the steps:

  1. In the settings.py either enable the app_directories template loader or set APP_DIRS to True on the TEMPLATES setting. And make sure that the app with the template overrides is somewhere above 'juntagrico' in the INSTALLED_APPS

    Alternatively, you can set DIRS to your TEMPLATES settings to the folder where you will place the template overrides.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'APP_DIRS': True,  # Option 1: This is needed for addons that override templates
        'DIRS': [os.path.join(BASE_DIR, 'templates')],  # Option 2: location of your overriding templates
        # ...
    },
]
  1. Create a template file in your templates folder (in your app or in the project root, depending on the above setting) with the same path as the template file in juntagrico, that you want to override.

  2. The project will now use your copy of the template instead of the original. If you only want to modify certain blocks on that template, extend the original template and modify the block(s) like this:

{% extends "path/to/this/template.html" %}
{% block block_to_override %}
    {{ block.super }} {#% insert the original content of this block, if you want %#}
    {#% add your own block content %#}
{% endblock %}