[英]How can I hide the description of form`s filed. Django
Good morning! 早上好!
I have such problem: I want to hide the django s description of form
s field. 我有这样的问题:我想隐藏
s description of form
字段的django s description of form
。 For example, 例如,
Required.
需要。 30 characters or fewer.
少于30个字符。 Usernames may contain alphanumeric, _, @, +, .
用户名可以包含字母数字,_,@,+ 、. and - characters.
和-字符。
it is the description of username field. 它是用户名字段的描述。 I want to hide it.
我要隐藏它。 My form:
我的表格:
class UserRegisterForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', 'password', 'email')
widgets = {
'username': forms.TextInput(attrs={
'class': 'form-control'
}),
'password': forms.PasswordInput(attrs={
'class': 'form-control'
}),
'email': forms.EmailInput(attrs={
'class': 'form-control'
}),
}
labels = {
'username': _(u"Логін"),
'password': _(u'Пароль'),
'email': _(u'Пошта')
}
What must i do? 我必须做什么?
You could set the help_text
of the concerned field to None
: 您可以将相关字段的
help_text
设置为None
:
def __init__(self, *args, **kwargs):
super(UserRegisterForm, self).__init__(*args, **kwargs)
self.fields['username'].help_text = None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.