如何在django中创建密码输入字段 [英] How to create password input field in django
本文介绍了如何在django中创建密码输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class UserForm(ModelForm):
class Meta:
password = forms.CharField(widget = forms.PasswordInput)
model = User
widgets = {
'password':forms.PasswordInput(),
}
但是我收到以下错误:NameError:name'forms'未定义。
我使用的是django 1.4.0版本。我遵循以下链接: Django密码问题
仍然得到相同的错误。我该怎么办。我在哪里得到错误。请帮助
解决方案
您需要在导入中包含以下内容:
从django导入表单
Hi i am using the django model class with some field and a password field. Instead of diplayin g regular plain text i want to display password input. I created a model class like this:
class UserForm(ModelForm):
class Meta:
password = forms.CharField(widget=forms.PasswordInput)
model = User
widgets = {
'password': forms.PasswordInput(),
}
But i am getting the following error: NameError: name 'forms' is not defined.
I am using django version 1.4.0. I followed this link : Django password problems
Still getting the same error. What should i do. Where am i getting wrong.Please help
解决方案
You need to include the following in your imports;
from django import forms
这篇关于如何在django中创建密码输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文