Usage

  1. Add some terms in the admin
  2. Choose how django-terms should apply to your website:

The added terms should now be automatically linked to their definitions.

Middleware

A middleware is available to automatically add links on all your website. It is not recommended to use it in production because it parses and rebuilds whole pages, which can be an overkill in most cases (even though django-terms has excellent performances).

It is also perfect for development: it never fails silently, unlike filters (see Exceptions for more details).

  1. Add 'terms.middleware.TermsMiddleware', to your MIDDLEWARE_CLASSES
  2. If the middleware applies to unwanted Django applications, HTML tags, classes, or IDs, set the corresponding Common settings

Template filter

A template filter is available to add links only on desired parts of your website.

  1. Choose one of your existing templates
  2. Add {% load terms %} to the beginning of the file (just after {% extends '[file]' %} if you have one)
  3. Use the filter replace_terms like every normal filter
  4. If the filter applies to unwanted HTML tags, classes, or IDs, set the corresponding :ref:Common settings

Example:

Suppose you have such a template:

{% extends 'base.html' %}

{% block article_header %}
  {{ article.header }}
{% endblock %}

{% block article_content %}
  {{ article.section1 }}
  {{ article.section2 }}
{% endblock %}

Here is how you can modify it:

{% extends 'base.html' %}
{% load terms %}

{% block article_header %}
  {{ article.header|replace_terms }}
{% endblock %}

{% block article_content %}
  {% filter replace_terms %}
    {{ article.section1 }}
    {{ article.section2 }}
  {% endfilter %}
{% endblock %}

Now, suppose you have an HTML class code-snippet in article.section2 where you do not want to add links on terms. Go to Common settings, and you will find the solution:

Add this line in settings.py:

TERMS_ADDITIONAL_IGNORED_CLASSES = ['code-snippet']

With django-CMS

A few tools are available to make your life easier if you use django-CMS.

Plugin processor

It will automatically apply the Template filter on every plugin.

To use it, add or modify CMS_PLUGIN_PROCESSORS in settings.py:

CMS_PLUGIN_PROCESSORS = (
    ...
    'terms.cms_plugin_processors.TermsProcessor',
    ...
)

Glossary plugin

This plugin displays all terms and their definitions.

Don’t forget to update CMS_PLACEHOLDER_CONF in your settings.py if you defined it, otherwise this plugin will not be available from your placeholders.

Apart from this, nothing to do to make it work.

App hook and menu

You can use the the app hook and the menu to integrate the complete glossary to your CMS architecture.

Nothing to do to make it work.