Template tags

Load the library in templates with {% load djcrud %}.

Filters

djcrud.templatetags.djcrud.html_attributes(attrs)[source]

Render attrs as a safe HTML attribute string.

Boolean True renders as a boolean attribute (name only). False renders as name="false". Other values are escaped and quoted. Keys that do not match a safe attribute name pattern are skipped.

Example:

{{ view.form_attributes|html_attributes }}
{{ action|unpoly_attributes:'model_menu'|html_attributes }}
djcrud.templatetags.djcrud.unpoly_attributes(target_view, context='')[source]

Return Unpoly link attributes for target_view in context.

When the active page view is available on request._djcrud_view, delegates to unpoly_link_attributes() so shell changes trigger a plain reload via FULL_PAGE_LINK_ATTRIBUTES. Otherwise falls back to unpoly_attributes() on target_view.

Pair with html_attributes() in templates:

{{ action|unpoly_attributes:'model_menu'|html_attributes }}

{% eval %} tag

djcrud.templatetags.djcrud.do_eval(parser, token)[source]

{% eval %} template tag — call a callable and assign the result.

Syntax:

{% eval callable positional_arg keyword=value as variable_name %}

callable is a template variable path (for example view.pagination_url). Positional and keyword arguments are resolved in the template context and passed to the callable. The return value is stored in variable_name for the remainder of the template.

Example:

{% load djcrud %}
{% eval view.pagination_url 2 as url %}
<a href="{{ url }}">Page 2</a>

{% eval view.some_method "arg" user=view.request.user as result %}