cms.core.templatetags package

Submodules

cms.core.templatetags.buildfiles module

cms.core.templatetags.buildfiles.build_ondemand(name, device, mode=None)

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.buildfiles.get_tag(staticfiles, mode)

cms.core.templatetags.cms_graph_models module

class cms.core.templatetags.cms_graph_models.IndentByNode(nodelist, indent_level, if_statement)

Bases: django.template.base.Node

render(context)
cms.core.templatetags.cms_graph_models.indentby(parser, token)

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

class cms.core.templatetags.cms_staticfiles.StaticFilesNode(varname=None, path=None)

Bases: django.templatetags.static.StaticNode

url(context)
cms.core.templatetags.cms_staticfiles.static_protocol(parser, token)

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

class cms.core.templatetags.cms_tags.ContextUpdatingNode(kwargs)

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.

get_content(context)
render(context)
class cms.core.templatetags.cms_tags.GenericContentNode(kwargs)

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 and varname 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 default QuerySet for the specified model (filtered as described above) will be available as self.query_set if you want to work with it.
get_content(context)
get_objects(context)
class cms.core.templatetags.cms_tags.SingleObjectNode(kwargs)

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.

get_content(context)
get_objects(context)
class cms.core.templatetags.cms_tags.UrlForNode(item, kwargs, varname=None)

Bases: django.template.base.Node

render(context)
cms.core.templatetags.cms_tags.boolean_icon(value)
cms.core.templatetags.cms_tags.cookie_banner(context)
cms.core.templatetags.cms_tags.extract_token(token)
cms.core.templatetags.cms_tags.gen_hint(*args, **kwargs)
cms.core.templatetags.cms_tags.get_latest_object(parser, token)

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 %}
cms.core.templatetags.cms_tags.get_latest_objects(parser, token)

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 %}
cms.core.templatetags.cms_tags.get_mark_label(obj)

Return the mark-value as span-element. Only usable for Displayable-models

cms.core.templatetags.cms_tags.get_mark_label_new(date, days=7)

Return a new span-element if item_date is not older than given days

cms.core.templatetags.cms_tags.get_netloc(*args, **kwargs)
cms.core.templatetags.cms_tags.get_schema_for_item(context, obj, image=None, image_thumbnail=None)
cms.core.templatetags.cms_tags.get_single_object(parser, token)

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 %}
cms.core.templatetags.cms_tags.get_status_label(obj)
cms.core.templatetags.cms_tags.get_verbose_name(obj)
cms.core.templatetags.cms_tags.image_or_gravatar_url(obj=None, size=32, version=None)
cms.core.templatetags.cms_tags.image_or_gravatar_url_as(obj=None, size=32, version=None)
cms.core.templatetags.cms_tags.is_installed_app(*args, **kwargs)
cms.core.templatetags.cms_tags.is_int(value)
cms.core.templatetags.cms_tags.obfuscate(value)
cms.core.templatetags.cms_tags.pagination_for(context, page, view=None, query=None)
cms.core.templatetags.cms_tags.prepend_protocol(context, url)
cms.core.templatetags.cms_tags.regexpUser(value, user)
cms.core.templatetags.cms_tags.socialshare_for(context, url, lang, title=None, description=None)

Return rendered social-share template. Can easily extended.

cms.core.templatetags.cms_tags.split(*args, **kwargs)
cms.core.templatetags.cms_tags.split_first(*args, **kwargs)
cms.core.templatetags.cms_tags.split_to_columns(values, n)
cms.core.templatetags.cms_tags.split_to_rows(values, n)

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.cms_tags.startswith(*args, **kwargs)
cms.core.templatetags.cms_tags.strip_slashes(value)
cms.core.templatetags.cms_tags.truncatelist(value, length=None)
cms.core.templatetags.cms_tags.underscore(value)
cms.core.templatetags.cms_tags.url_for(parser, token)

cms.core.templatetags.form_tags module

cms.core.templatetags.form_tags.form_fields_for(context, form, exclude_fields=())

Renders fields for a form.

cms.core.templatetags.form_tags.form_help_enabled()
cms.core.templatetags.form_tags.form_hint(paragraph=True)
cms.core.templatetags.form_tags.form_validate()
cms.core.templatetags.form_tags.isinvalid(input, input2=None)

cms.core.templatetags.packages_tags module

cms.core.templatetags.packages_tags.get_packages()
cms.core.templatetags.packages_tags.get_packages_external()

cms.core.templatetags.robots_tags module

cms.core.templatetags.robots_tags.is_installed_app(*args, **kwargs)

cms.core.templatetags.table_tags module

cms.core.templatetags.table_tags.table_header(context, headers)

Inclusion-Tag for Sortable-Table-Headers

cms.core.templatetags.versioning_tags module

cms.core.templatetags.versioning_tags.get_cloc()

Module contents