[Answered ]-In Django forms.ModelChoiceField HOWTO restrict displayed choices but set one of the restricted values during cleanup

2👍

django/forms/models.py:1011 has this:

qs = self.queryset.filter(**{'%s__in' % key: value})

So it seems that if you overrode your custom field’s clean() method to modify self.queryset as necessary before calling super(MyField, self).clean(value), you could handle this edge case relatively cleanly.

Leave a comment