Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#10274 closed (fixed)

BaseGenericInlineFormSet.get_queryset calls .empty()

Reported by: Zak Johnson <zakj@…> Owned by: brosner
Component: Contrib apps Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In BaseGenericInlineFormSet.get_queryset():

        if self.instance is None:
            return self.model._default_manager.empty()

Managers don't have an empty() method; this should instead be get_empty_query_set(). Attached patch (against trunk revision 9836) includes a doctest to illustrate the problem.

Attachments (2)

BaseGenericInlineFormSet.diff (2.0 KB) - added by Zak Johnson <zakj@…> 6 years ago.
10274-generic-inline-formset-patch-and-test.diff (2.0 KB) - added by akaihola 6 years ago.
patch and tests with none() instead of empty()

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by Zak Johnson <zakj@…>

comment:1 Changed 6 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to brosner
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Wow, that must have been a brain dead commit by me. You are correct empty() is not on a manager, but none() would have been correct here. Thanks for the patch!

comment:2 Changed 6 years ago by Alex

I think what you really want is .none()

Changed 6 years ago by akaihola

patch and tests with none() instead of empty()

comment:3 Changed 6 years ago by brosner

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [9886]) Fixed #10274 -- Fixed an embarrassing mistake in BaseGenericInlineFormSet.get_queryset. Thanks Zak Johnson for the report and akaihola for the patch.

comment:4 Changed 6 years ago by brosner

(In [9887]) [1.0.X] Fixed #10274 -- Fixed an embarrassing mistake in BaseGenericInlineFormSet.get_queryset. Thanks Zak Johnson for the report and akaihola for the patch.

Backport of r9886 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top