[Answered ]-Django: iterating over the options in a custom select field

2👍

The magic of django forms is that you don’t need to do all that. By calling the form’s select field by name, it will render it and select the right option as based on initial/instance data passed into the form on instantation.

{{form.working_month}}

If you’re still having troubles, can you post the form class as well?

Good luck!

EDIT

In looking at the first comment on the link you posted, this issue is addressed. The commenter included this code

def __init__(self, *args, **kwargs):
  forms.MultiValueField.__init__(self, *args, **kwargs)
  self.fields = (forms.CharField(), forms.CharField(),)

0👍

Leave a comment