简体   繁体   English

我如何隐藏表单提交的描述。 Django的

[英]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.

相关问题 Django ORM 将数据添加到现有的 JSONb 文件中。 - Django ORM to add data into existing JSONb filed. django 如何隐藏特定表单提交和循环数据输入 - django how to hide specific form filed and loop data input 如何在自定义 django 表单中隐藏 django 标签? - How can I hide a django label in a custom django form? 对于博客文章,我使用了 many_to_many 提交的标签。 现在我尝试使用 Django_Taggit 作为标签字段,但是在迁移时我遇到了一些错误 - For blog post i used tags by many_to_many filed. Now i try to use Django_Taggit for tag field, but i face some error while migrate 如何通过Django外键描述进行查询? - How can I make a query by a Django foreignkey description? 如何在表单 django 中添加登录的用户名 - How can I add the logged in user's name in form django Django mptt,我可以删除默认的“名称”归档吗? - Django mptt, can I delete the default 'name' filed? 我如何更改Django模型的默认描述。 - How can I change the default description of a Django models.ForeignKey 我如何在html(Django项目)上显示日期的值,但是月份的3个字母 - How can I display on html (Django project), value of date filed but, the month 3 letters 提交后如何隐藏表格? - How can I hide a form after submission?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM