How do I add a text box next to a radio button using django forms? I already got the setup for the radio buttons alone.
I would also like to store the value of the text box instead of "Other".
forms.py
from django import forms
from .models import MyModel
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
fields = (
'question',
)
widgets = {
'question': forms.RadioSelect,
}
models.py
class MyModel(TimeStampedModel):
Choice1 = "Choice 1"
Choice2 = "Choice 2"
Other = "Other"
MyModel_Choices = (
(Choice1 = 'Choice 1'),
(Choice2 = 'Choice 2'),
(Other = 'Other'),
)
question = models.CharField(
_('Question'),
max_length=100,
choices=MyModel_Choices,
help_text='Help Text'
)
Expected Output:
Question:
- Choice1
- Choice2
- Other [textbox]
Help Text