如何在Django中获取表单字段的id? [英] How to get form field's id in Django?

查看:109
本文介绍了如何在Django中获取表单字段的id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在HTML中我可以得到:< input name = field_nameid =id_field_name...



我知道我可以用 {{field .html_name}} ,但是有没有什么类似的获取id?

或者我可以这样得到: id _ {{field.html_name

解决方案

您可以获得ID:

  {{field.auto_id}} 


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

In the HTML I get: <input name="field_name" id="id_field_name"...

I know I can get the name with {{ field.html_name }}, but is there anything similar for getting the id?
Or can I only get it like this: id_{{ field.html_name }}?

解决方案

You can get the ID like this:

{{ field.auto_id }}

这篇关于如何在Django中获取表单字段的id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆