[Django]-Dynamicly update the queryset of ModelMultipleChoiceField in ModelForm

9👍

✅

Just move it after the super() call().

def __init__(self, users_list, **kw):
    super(BaseWriteForm, self).__init__(**kw)
    self.fields['recipients'].queryset = User.objects.filter(pk__in=users_list)

Leave a comment