我想以表格的形式添加国家和城市,但我正在使用django-countries作为国家/地区,但出现此错误:
file_b
forms.py:
file_c
models.py:自定义用户模型
pipe(2)
view.py:
django.core.exceptions.FieldError: Unknown field(s) (country) specified for CustomUser
from django import forms
from django.contrib.auth.forms import UserCreationForm
from bootstrap_datepicker_plus import DatePickerInput
from tempus_dominus.widgets import DatePicker
from .models import CustomUser
from django_countries.fields import CountryField
class RegistrationForm(UserCreationForm):
CHOICES = (
(0, 'celebrities'),
(1, 'singer'),
(2, 'comedian'),
(3, 'dancer'),
(4, 'model'),
(5, 'Photographer')
)
Mobile_Number = forms.CharField(label='Mobile Number', widget= forms.NumberInput)
Artist_Category = forms.ChoiceField(choices=CHOICES)
bio = forms.CharField(widget=forms.Textarea,label = 'something about yourself')
portfolio = forms.URLField(label = 'enter your portfolio')
country = CountryField(blank_label = '(select_country)')
# country = forms.co
class Meta:
model = CustomUser
fields = ('email','password','Mobile_Number','Artist_Category','portfolio','country','bio',)
............................................... ................................................... ..........................