开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜