Subject: ModelFormSet validation fails when initial queryset contains objects not in the default manager's queryset
Hi everyone,

I have a ModelForm and a ModelFormSet. I initialize my ModelFormSet with a
queryset containing objects from a custom manager that is not the model's
default manager. My formset does not validate, because ModelForms with
instances that are objects in my queryset but not in the model's default
manager's queryset don't have valid ids.

My code: http://dpaste.org/d6V9y/

I think I'm seeing this because the add_fields method of BaseModelFormSet
has the line (659) qs = self.model._default_manager.get_query_set().
I can get my code to work by subclassing BaseModelFormset and setting form.
fields[self._pk_field.name].queryset= self.get_queryset() (thanks to some
help in irc).
My question is why the default manager's queryset is used instead of
self.get_queryset().

Thanks,

Tom

--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-developers/-/vG8eLJIA740J.
To post to this group, send email to django-developers@xxxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
django-developers+unsubscribe@xxxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.

(C)2011 mailinglist-archive.com