Use field label as placeholder with django-widget-tweaks

喜夏-厌秋 提交于 2019-12-05 21:34:11

I am now using render_field to render the field instead of using template filters and it seems to work.

<div class="col-sm-10">
  {% render_field field class="form-control" placeholder=field.label %}
  {% if field.help_text %}
     <p class="help-block"><small>{{ field.help_text }}</small></p>
  {% endif %}
</div>

It seems form variables cannot be used within template filters and can only be used with render_field (though the django-widget-tweaks documentation doesnt say that explicitly).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!