开发者

Can't get rid of labels that are generated in django forms

开发者 https://www.devze.com 2023-01-27 03:23 出处:网络
I can\'t seem to get rid of the labels that are generated by the forms class. I found another question that seemed to have the same problem. He added \"auto_id=False\" to his form class and it seemed

I can't seem to get rid of the labels that are generated by the forms class. I found another question that seemed to have the same problem. He added "auto_id=False" to his form class and it seemed to have worked, but it didn't for me.

Here is my code as it currently stands:

from django import forms

c开发者_运维技巧lass EmailSubmit (forms.Form):
auto_id=False
email = forms.EmailField(
              widget=forms.TextInput(attrs={'class':'submit'}))

f = EmailSubmit()


If you do something like this in your template than you can print just the fields instead of the labels aswell:

{{ form.field.as_widget }}

And for the label, if you need it for some parts:

{{ form.field.label_tag }}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号