Dropdown Not updating

Hey,

I have a user creation form has an dropdown value “Company” whose entries are filled as below:

`

try:
    company_choices  = set()

    for obj in Company.objects.all():
        company_choices.add((obj.name, obj.name))

except OperationalError:
    company_choices  = set()
company = forms.ChoiceField(required=True, choices=company_choices, label="Company")`

The companies are being added by a superuser account using another form.

The user creation form with this “country” drop-down does not update until I restart the server again.
Any idea on how to fix this issue?

Thank you.

Please post the complete form, along with the view using it.

Hi Ken,

Thank you. I have moved the above code snippet to the init() of the form class and it started to work just fine.

Thank you.