I am creating a form that uses MultipleChoiceField. The values ββfor this field are derived from another model. This method works fine, but I notice (on the production server) that when adding a new element to the model in question (NoticeType) the form does not dynamically update. I have to restart the server for a new item to be displayed on my MultipleChoiceField.
Any changes to the NoteType model (editing elements or creating new ones) do not apply to the form. After restarting the production server, updates will appear.
Any ideas why this could be? The relevant part of the form is given below. Thanks.
from django import forms from django.contrib.auth.models import User from notification.models import NoticeType class EditUserProfileForm(forms.Form): CHOICES = [] for notice in NoticeType.objects.all(): CHOICES.append( (notice.label,notice.display) ) notifications = forms.MultipleChoiceField( label="Email Notifications", required=False, choices=( CHOICES ), widget=forms.CheckboxSelectMultiple,)
source share