django-widget-tweaks

Use field label as placeholder with django-widget-tweaks

亡梦爱人 提交于 2019-12-22 10:30:12
问题 I am using django-widget-tweaks and unable to figure out how to add a field variable as placeholder , like the following: <div class="col-sm-10"> {{ field|append_attr:"class:form-control"|append_attr:"placeholder:field.label" }} {% if field.help_text %} <p class="help-block"><small>{{ field.help_text }}</small></p> {% endif %} </div> field.label above does not evaluate and puts the string "field.label" as the placeholder on the page. Some SO posts suggest registering a custom tag/filter which

Use field label as placeholder with django-widget-tweaks

喜夏-厌秋 提交于 2019-12-05 21:34:11
I am using django-widget-tweaks and unable to figure out how to add a field variable as placeholder , like the following: <div class="col-sm-10"> {{ field|append_attr:"class:form-control"|append_attr:"placeholder:field.label" }} {% if field.help_text %} <p class="help-block"><small>{{ field.help_text }}</small></p> {% endif %} </div> field.label above does not evaluate and puts the string "field.label" as the placeholder on the page. Some SO posts suggest registering a custom tag/filter which seems complicated for something this simple. I am now using render_field to render the field instead