Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25683 closed Bug (fixed)

1.8.6 regression: ModelChoiceField no longer accepts Manager objects as queryset

Reported by: Marti Raudsepp Owned by: nobody
Component: Forms Version: 1.8
Severity: Release blocker Keywords:
Cc: Tim Graham, marti@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi! It seems that the fix for #25496 caused a regression. When one uses ModelChoiceField(queryset=FooModel.objects) then it throws:

Traceback (most recent call last):
  File "/home/marti/workspace/django/tests/forms_tests/tests/tests.py", line 93, in test_modelchoicefield_manager
    self.assertTrue(list(f.choices))
  File "/home/marti/workspace/django/django/forms/models.py", line 1095, in __iter__
    method = 'all' if self.queryset._prefetch_related_lookups else 'iterator'
AttributeError: 'Manager' object has no attribute '_prefetch_related_lookups'

I have a patch in development to fix this, should be ready soon.

Change History (5)

comment:1 by Marti Raudsepp, 9 years ago

Cc: marti@… added
Last edited 9 years ago by Marti Raudsepp (previous) (diff)

comment:2 by Iacopo Spalletti, 9 years ago

Triage Stage: UnreviewedAccepted
Version 0, edited 9 years ago by Iacopo Spalletti (next)

comment:3 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 1155843a:

Fixed #25683 -- Allowed ModelChoiceField(queryset=...) to accept Managers.

This fixes a regression from refs #25496.

comment:5 by Tim Graham <timograham@…>, 9 years ago

In 8db5122d:

[1.9.x] Fixed #25683 -- Allowed ModelChoiceField(queryset=...) to accept Managers.

This fixes a regression from refs #25496.

Backport of 1155843a41af589a856efe8e671a796866430049 from master

comment:4 by Tim Graham <timograham@…>, 9 years ago

In 3144785:

[1.8.x] Fixed #25683 -- Allowed ModelChoiceField(queryset=...) to accept Managers.

This fixes a regression from refs #25496.

Backport of 1155843a41af589a856efe8e671a796866430049 from master

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