Get type of Django form widget from within template

前端 未结 6 1501
你的背包
你的背包 2020-12-01 01:27

I\'m iterating through the fields of a form and for certain fields I want a slightly different layout, requiring altered HTML.

To do this accurately, I just need to

6条回答
  •  無奈伤痛
    2020-12-01 02:06

    As of Django 1.11, you can just use widget.input_type. Example:

    {% for field in form.visible_fields %}
        
    {% endfor %}
    

提交回复
热议问题