How to get form field's id in Django?

前端 未结 4 1576
庸人自扰
庸人自扰 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:11

    This doesn't work for every form field.

    For instance {{ form.address.auto_id }} works while {{ form.address.auto_name }} will not.

    However you can use {{ form.address.html_name }} to get the equivalent answer.

    Here are the docs

提交回复
热议问题