How to get form field's id in Django?

前端 未结 4 1568
庸人自扰
庸人自扰 2020-12-23 03:03

Is there any way to get the id of a field in a template?

In the HTML I get:

I know I can g

4条回答
  •  轮回少年
    2020-12-23 03:30

    In Django 2 you can retrieve the ID for a specific field using {{ field.id_for_label }}

    This is documented here.

提交回复
热议问题