You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The template tag {% crispy_field %} allows setting additional attributes to be rendered on the HTML tag. The expansion / resolving of the values is restricted to a variable defined in the template’s context and does not allow using filters.
This is due to the usage of template.Variable, while template.FilterExpression should have been used.
Example code:
{% crispy_field field "data-question" var_q|default_if_none:"?" %}
Expected
The resulting HTML page includes an <input> tag with data-question="?" attribute if var_q is None and with data-question="how?" attribute if var_q is "how?".
Actual behavior
The following template error:
VariableDoesNotExist
Failed lookup for key [var_q|default_if_none:"?"] in context.
Description
The template tag
{% crispy_field %}
allows setting additional attributes to be rendered on the HTML tag. The expansion / resolving of the values is restricted to a variable defined in the template’s context and does not allow using filters.This is due to the usage of
template.Variable
, whiletemplate.FilterExpression
should have been used.Example code:
Expected
The resulting HTML page includes an
<input>
tag withdata-question="?"
attribute ifvar_q
is None and withdata-question="how?"
attribute ifvar_q
is "how?".Actual behavior
The following template error:
Offending lines: https://github.com/django-crispy-forms/django-crispy-forms/blob/1.12.0/crispy_forms/templatetags/crispy_forms_field.py#L150-L153
The text was updated successfully, but these errors were encountered: