cms.core.templatetags package¶
Submodules¶
cms.core.templatetags.buildfiles module¶
A template tag that returns the URL to a file using staticfiles’ storage backend
Usage:
{% build_ondemand path device mode [as varname] %}
Examples:
{% build_ondemand "leaflet" device="default" %} {% build_ondemand variable_with_path device %} {% build_ondemand "leaflet" device="default" mode="css" %} {% build_ondemand variable_with_path device mode %} {% build_ondemand "leaflet" as leaflet_base %} {% build_ondemand variable_with_path as varname %}
If mode is None, asume we should collect css and js files.
cms.core.templatetags.cms_graph_models module¶
Bases:
django.template.base.Node
Adds indentation to text between the tags by the given indentation level.
{% indentby <indent_level> [if <statement>] %} ... {% endindentby %}
- Arguments:
- indent_level - Number of spaces to indent text with. statement - Only apply indent_level if the boolean statement evalutates to True.
cms.core.templatetags.cms_staticfiles module¶
Bases:
django.templatetags.static.StaticNode
A template tag that returns the URL to a file using staticfiles’ storage backend
Usage:
{% static path [as varname] %}
Examples:
{% static "myapp/css/base.css" %} {% static variable_with_path %} {% static "myapp/css/base.css" as admin_base_css %} {% static variable_with_path as varname %}
cms.core.templatetags.cms_tags module¶
Bases:
django.template.base.Node
Node that updates the context with certain values.
Subclasses should define
get_content()
, which should return a dictionary to be added to the context.
Bases:
cms.core.templatetags.cms_tags.ContextUpdatingNode
Base Node class for retrieving objects from any model.
By itself, this class will retrieve a number of objects from a particular model (specified by an “app_name.model_name” string) and store them in a specified context variable (these are the
num
,model
andvarname
arguments to the constructor, respectively), but is also intended to be subclassed for customization.- Subclass and override
_get_queryset
; all that’s expected - is that it will return a
QuerySet
which will be used to retrieve the object(s). The defaultQuerySet
for the specified model (filtered as described above) will be available asself.query_set
if you want to work with it.
- Subclass and override
Bases:
cms.core.templatetags.cms_tags.ContextUpdatingNode
Node
subclass which retrieves a single object – by primary-key lookup – from a given model.Because this is a primary-key lookup, it is assumed that no other filtering is needed; hence, the settings-based filtering performed by
GenericContentNode
is not used here.
Bases:
django.template.base.Node
Retrieves the latest object from a given model, in that model’s default ordering, and stores it in a context variable.
Syntax:
{% get_latest_object [app_name].[model_name] as [varname] %}
Example:
{% get_latest_object comments.freecomment as latest_comment %}
Retrieves the latest
num
objects from a given model, in that model’s default ordering, and stores them in a context variable.Syntax:
{% get_latest_objects model=[app_name].[model_name] num=[num] filter_[filter]=[value] (prefetch=[prefetch - comma-separated]) as [varname] %}
Example:
{% get_latest_objects model=articles.articlesitem num=3 filter_categories__slug=news as items %}
Return the mark-value as span-element. Only usable for
Displayable
-models
Return a
new
span-element if item_date is not older than given days
Retrieves a specific object from a given model by primary-key lookup, and stores it in a context variable.
Syntax:
{% get_single_object model=[app_name].[model_name] filter_pk=[pk] as [varname] %}
Example:
{% get_single_object model=articles.articlescategory filter_pk=1 as category %}
Return rendered social-share template. Can easily extended.
Break a list into sublists of length
n
. That is,partition(range(10), 4)
gives:[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10]]
cms.core.templatetags.robots_tags module¶
cms.core.templatetags.table_tags module¶
Inclusion-Tag for Sortable-Table-Headers