About this document
This document describes the templates, template tags and filters provided by the library.
See also the modules documentation.
It's possible to override any template by providing an equally named file inside an utils subdirectory somewhere in TEMPLATE_DIRS where Django can find it.
This is the template used by the template tag paginator. The template displays pagination links. See below for more information.
Template tags and filters are defined in modules contained inside the templatetags directory.
These can be loaded using {% load TAGMODULE %} in your templates.
{% load paginator %}
An inclusion tag, using the template utils/paginator.html.
This is a pagination template tag, to be used in conjunction with the default Django pagination mechanism and/or object list generic views (either the Django object_list built-in, or the versions provided by softwarefabrica.django.crud).
In addition to the context variables provided by the standard object_list generic view, this adds others for use in displaying first, adjacent and last page links.
Receives the optional arguments:
The variables added to the context are:
Usage:
{% paginator %}
{% load sitevars %}
Populates the template context with some variables from the project settings.
As an alternative method to this tag, it's also possible to use the template context processor context_vars provided in softwarefabrica.django.utils.viewshelpers (see the modules documentation).
The variables pushed into the context are:
Usage:
{% sitevars %}
{% load urlsave %}
This is similar to Django url template tag, but it doesn't produce any output, and saves the result into a context variable.
Usage:
{% urlsave path.to.some_view arg1,arg2,name1=value1 as myurlvar %}
{% load forward_query_param %}
Implements the forward_query_param template tag described in Paginating complex queries. It allows to propagate values of the request GET through forms.
Usage:
{% forward_query_param "MY_GET_VARIABLE" %}
(to be used inside a <form>...</form>).
NOT YET PROVIDED
{% load in_list %}
Returns a boolean indicating if its first argument is present in its second argument (typically a list or a tuple).
Usage:
{% if user|in_list:cool_people %}You're cool!{% else %}Don't lose hope :-){% endif %}
NOT YET PROVIDED
{% load sanitize %}
Returns a sanitized version of its argument, with dangerous HTML code removed. Non dangerous tags (<p>, <i>, <strong>, <b>, <u>, <h1>, <h2>, <h3>, <pre>, <br>, <a>, <img>), are left in place. For <a> and <img> tags, the href attribute is stripped off inline Javascript code, if any.
Usage:
{{ user_text|sanitize }}