I have a form which I want the user to select a level. However, my model is coming up with issues that there are too many values to unpack.
I have tried to put the options which are required in a list as I found that worked before but for some reason it won't work this time.
Model I'm trying to access:
class Status(models.Model):
status_level=models.CharField(max_length=15)
def __str__(self):
return self.status_level
def __iter__(self):
return iter(self.status_level)
The form itself:
FLAG_CHECKBOX=[('active','Active'),('inactive','Inactive'),] STATUS_CHECKBOX=[(Status.objects.all()),]
class Add_Event_Form(forms.ModelForm):
event_title=forms.CharField(max_length=50,help_text="Please enter an informative title.")
event_status=forms.MultipleChoiceField(choices=STATUS_CHECKBOX,widget=forms.CheckboxSelectMultiple,help_text="Please select the status of the event")
event_description=forms.CharField(max_length=500, initial="", help_text="Enter a short description of the event here")
event_flag=forms.MultipleChoiceField(choices=FLAG_CHECKBOX,required=True,widget=forms.CheckboxSelectMultiple,help_text="Please select the status of this event.")
date_active=forms.DateField(required=True, widget=forms.DateInput(attrs={'class':'datepicker'}), help_text="Please select a date for this event.")
time_active=forms.TimeField(required=True, widget=forms.TimeInput(format='%HH:%MM'), help_text="Please select a time for this event.")
The line which is flagged where the error occurs:
H:\interview\server_status\views.py in add_event
return render(request,'server_status/add_event.html',{'form':form})
return self.get_renderer(name, value, attrs, choices).render() ...
▼ Local vars
Variable Value
self
<django.forms.widgets.CheckboxSelectMultiple object at 0x0403A0D0>
choices
()
name
'event_status'
value
None
attrs
{u'id': u'id_event_status'}
C:\Python27\lib\site-packages\django\forms\widgets.py in render
choice_value, choice_label = choice ...
▼ Local vars
Variable Value
id_
u'id_event_status'
i
0
self
<django.forms.widgets.CheckboxFieldRenderer object at 0x0406DE90>
start_tag
u'<ul id="id_event_status">'
choice
[<Status: Critical>, <Status: Medium>, <Status: Low>]
output
[u'<ul id="id_event_status">']
If you require additional information let me know.