Reputation: 2615
I want to make select phone service agency when user sign up. but my select form doesn't appear in the html. is there any way to make select form?
models.py
class User(AbstractUser):
...
phone_service_provider = models.CharField(
max_length=11, choices=AGENCY_CHOICES, blank=False
)
...
forms.py:
class SignUpGeneralForm(forms.Form):
...
address_postcode_general = forms.CharField(
widget=forms.TextInput(
attrs={
"id": "postcode",
"placeholder": "우편번호",
"class": "appearance-none bg-transparent border-none w-full text-gray-700 mr-3 py-1 px-2 leading-tight focus:outline-none",
"style": "width:100%; height:100%;",
"readonly": "true",
}
)
)
phone_service_provider = forms.ChoiceField(
widget=forms.Select(choices=AGENCY_CHOICES)
)
phone_number = forms.CharField(
widget=forms.TextInput(
attrs={
"placeholder": "핸드폰 번호",
"class": "appearance-none bg-transparent border-none w-full text-gray-700 mr-3 py-1 px-2 leading-tight focus:outline-none",
"style": "width:100%; height:100%;",
}
)
)
...
Upvotes: 0
Views: 68
Reputation: 708
widget in formsField is only for html attributes, the choices need to be in Field, no widgets, so :
phone_service_provider = forms.ChoiceField(
widget=forms.Select(),
choices=AGENCY_CHOICES
)
Upvotes: 1