我有以下表格:
class AlertForm(forms.Form):
user_choices = sorted([(c.id, c.first_name + ' ' + c.last_name) \
for c in User.objects.all()], key=lambda user: user[1])
message = forms.CharField(widget=forms.Textarea())
recipients = forms.MultipleChoiceField(choices=user_choices,
widget=forms.SelectMultiple(attrs={'size':'20'}),
help_text="You will automatically be included with the recipients.")
问题是如果我使用管理界面或任何其他方法将用户添加到数据库中,我必须重新启动服务器,新添加的用户才会出现在 MultipleChoiceField 中。如何避免服务器重启?