[Answer]-AttributeError: 'NoneType' object has no attribute 'all'

1👍

Your original error comes from declaring the ModelChoiceField with a None queryset and never assigning one before the post. Try adding a get function, something like this:

def get(self, request, *args, **kwargs):
   form = locationForm()
   # Assing proper ModelChoice queryset.
   form.fields['existing_regions'].queryset = Region.objects.filter(
      location__manager=self.request.user)
   # Here put the rest of your get code...

Also, since you are using a CBV, have you considered using a FormView instead of the plain View?

Leave a comment