-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Tom,
On 02/20/2012 10:58 PM, Tom wrote: > 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(). On initial inspection I'd say you're right; it seems like self.get_queryset() should be used there rather than assuming the default manager's queryset. Can't be sure until I look into it more closely - the next step would be to file a ticket at code.djangoproject.com, ideally with a patch containing a failing test case integrated into Django's own test suite. Thanks for the report! Carl -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9Du3EACgkQ8W4rlRKtE2cPdwCeLId9F+VVVVFYEPGvuq6vpp+I Pn4AoMUeSvU8msQ22lGgneeUA+/g58b7 =Tv81 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
