Topic: Radio buttons not showing from Django form rendering in html
Expected behavior Radio buttons are shown in html when rendering from a Django form Actual behavior Don't see the radio buttons any more, just the labels associated with the radio buttons. If I remove MDBootstrap buttons are shown, but I am using lots of the great features from MDB and would like to keep using Resources (screenshots, code snippets etc.)
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Open
Specification of the issue
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: Laptop
- Browser: Edge
- OS: Windows
- Provided sample code: No
- Provided link: No
Tags
Related topics
Bartłomiej Malanowski staff pro premium commented 5 years ago
how can we reproduce your issue?
Beaker42 commented 5 years ago
Hi,
It a Django form being rendered in HTML. The field type being passed from the form is RadioSelect.
Hope this helps.
Many thanks, Nicholas
Bartłomiej Malanowski staff pro premium commented 5 years ago
Can you show us your code?
Beaker42 commented 5 years ago
Here are snippets of the code, the issue is with the radio buttons for feesontop in the Model Event, using the form EventMe. The EventMe form specifies that the field is a RadioSelect, which is passed through to the HTML page. What I see is the label relating to 'TicketChoice' (below) but no radio button, so it is not possible to choose an option.
I have successfully used MDS for datatables, charts and buttons so it seems to be installed correctly.
model.py (snippet)
TicketChoice=[ ('feecust', 'Fee on top of ticket price'), ('feeticket', 'Fee in ticket price'), ]
class Event(models.Model): organiser = models.ForeignKey(User, on_delete=models.CASCADE,) eventname = models.CharField(verbose_name='Event Name', max_length=40, unique=True) eventdescription = models.CharField(verbose_name='Event Description', max_length=400) eventcategory = models.CharField(verbose_name='Event Category', choices=CategoryChoice, max_length=40, null=True) startdate = models.DateField(verbose_name='Start Date') starttime = models.TimeField(verbose_name='Start Time') enddate = models.DateField(verbose_name='End Date') endtime = models.TimeField(verbose_name='End Time') feesontop = models.CharField(max_length=20, choices=TicketChoice, default='feecust', verbose_name='Fee choice') forms.py
class EventMe(forms.ModelForm): class Meta: model = Event fields = ['eventname','eventdescription', 'eventcategory', 'startdate', 'starttime','enddate', 'endtime', 'feesontop', 'eventimage', 'contactemail', 'eventwebsite']
Then the views.py just sends the EventMe form to render in HTML, and the field for ticket choice is rendered in the html like this:
events.html
{% bootstrap_field eventsetup_form.feesontop %}
Beaker42 commented 5 years ago
Hi, is anyone able to take a look at this please?
Many thanks, Nick