我正在使用 Django 1.7 并且刚刚安装了 localflavor 1.1。现在,在创建默认用户时,我想使用该USStateSelect()
字段。在创建扩展默认用户的护士时,我遇到了各种错误。这是我当前的代码:
模型.py:
from localflavor.us.forms import USStateSelect
class MyUser(AbstractBaseUser):
#Address
house_number = models.IntegerField(default = 0)
street = models.CharField(max_length = 30, default = "")
city = models.CharField(max_length = 20, default = "")
state = USStateSelect()
zip_Code = models.IntegerField(default = 0)
class Nurse(MyUser):
#Other fields
表格.py:
class NurseCreationForm(ModelForm):
password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput)
class Meta:
model = Nurse
fields = ('email', 'first_name', 'last_name', 'department','state',)
错误:
File "C:\Python34\lib\site-packages\django\forms\models.py", line 294, in
__new__raise FieldError(message)
django.core.exceptions.FieldError: Unknown field(s) (state) specified for
Nurse
我无法在网上的任何地方找到适用于 Django 1.7 的有效解决方案。在此先感谢您的帮助!