2👍
✅
Category.objects.filter(children__isnull=True)
class MyModelForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(MyModelForm, self).__init__(*args, **kwargs)
self.fields['myfield'].queryset = Category.objects.filter(children__isnull=True)
Source:stackexchange.com