Fixed #9076 -- Changed BaseInlineFormSet to not override BaseModelFormSet's get_queryset method. BaseInlineFormSet's method did not include a couple of fixes/enhancements that were made to the parent's method, resulting in excessive queries (some of which can return bad data due to #9006) for admin pages with inlines.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
02e67bba47
commit
bca14cd3c8
|
@ -463,7 +463,9 @@ class BaseInlineFormSet(BaseModelFormSet):
|
||||||
self.save_as_new = save_as_new
|
self.save_as_new = save_as_new
|
||||||
# is there a better way to get the object descriptor?
|
# is there a better way to get the object descriptor?
|
||||||
self.rel_name = RelatedObject(self.fk.rel.to, self.model, self.fk).get_accessor_name()
|
self.rel_name = RelatedObject(self.fk.rel.to, self.model, self.fk).get_accessor_name()
|
||||||
super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix or self.rel_name)
|
qs = self.model._default_manager.filter(**{self.fk.name: self.instance})
|
||||||
|
super(BaseInlineFormSet, self).__init__(data, files, prefix=prefix or self.rel_name,
|
||||||
|
queryset=qs)
|
||||||
|
|
||||||
def _construct_forms(self):
|
def _construct_forms(self):
|
||||||
if self.save_as_new:
|
if self.save_as_new:
|
||||||
|
@ -479,14 +481,6 @@ class BaseInlineFormSet(BaseModelFormSet):
|
||||||
form.data[form.add_prefix(self._pk_field.name)] = None
|
form.data[form.add_prefix(self._pk_field.name)] = None
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
"""
|
|
||||||
Returns this FormSet's queryset, but restricted to children of
|
|
||||||
self.instance
|
|
||||||
"""
|
|
||||||
kwargs = {self.fk.name: self.instance}
|
|
||||||
return self.model._default_manager.filter(**kwargs)
|
|
||||||
|
|
||||||
def save_new(self, form, commit=True):
|
def save_new(self, form, commit=True):
|
||||||
kwargs = {self.fk.get_attname(): self.instance.pk}
|
kwargs = {self.fk.get_attname(): self.instance.pk}
|
||||||
new_obj = self.model(**kwargs)
|
new_obj = self.model(**kwargs)
|
||||||
|
|
Loading…
Reference in New Issue