I have created user signup form in Django3.
In the form I want to have a radio button based choice selection for the user.
The forms.py looks like
class SignUpForm(UserCreationForm):
....
subscription_choice = (
('yearly', 'Yearly'),('monthly', 'Monthly'),
)
subscription_type = forms.TypedChoiceField(
choices = subscription_choice,
widget = forms.RadioSelect(attrs={
"style": "display: inline-block"
})
The model file looks like.
class SignUp(AbstractBaseUser):
subscription_choice = (
('yearly', 'Yearly'),('monthly', 'Monthly'),
)
email = models.EmailField(unique=True)
firstname = models.CharField(max_length=150)
lastname = models.CharField(max_length=150)
phonenumber = models.CharField(max_length=14,primary_key=True)
referral_code = models.CharField(max_length=150, default="None")
subscription_type = models.CharField(max_length=10, default="monthly", choices=subscription_choice)
....
I have tried some css tricks as suggested in some answers on SO but no luck.
The result I am getting is vertical aligned (messy) radio buttons.
Need some help.