Opened 13 years ago

Closed 12 years ago

#1113 closed defect (fixed)

OneToOneField with limit_choices_to breaks ChangeList

Reported by: Nebojša Đorđević - nesh <nesh@…> Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: nesh@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When I use OneToOneField in the model with limit_choices_to change list in admin breaks with:

got unexpected keyword argument 'category__type__exact'

where category__type__exact is limit_choices_to argument.

Problem seems to go away when I comment-out following lines in admin/views/ (from line 229):

        if opts.one_to_one_field:

Bug or feature? :)

Attachments (1)

1113.patch (1.5 KB) - added by Jacob 12 years ago.
Hopefully a final fix :)

Download all attachments as: .zip

Change History (5)

comment:1 Changed 12 years ago by James Bennett

Bug. Definitely bug.

Just ran into this myself (on the pre-magic-removal tag, so I haven't checked to see if this bug migrated to 0.95); the offending lines nesh pointed out will cause the limit_choices_to kwargs to be used in a query against the model's table instead of against the related object's table, so I don't see what purpose they serve.

comment:2 Changed 12 years ago by James Bennett <ubernostrum@…>

Resolution: fixed
Status: newclosed

Fixed in [3576]

comment:3 Changed 12 years ago by Jacob

Resolution: fixed
Status: closedreopened

So as far as I can tell, the offending lines don't actually fix this pretty subtle problem. It appears looking at the pre-new-admin work that a few lines of code ( got left out in the move to the new admin; removing these two lines masked he problem but still broke one-to-one.

A patch that seems to work follows...

Changed 12 years ago by Jacob

Attachment: 1113.patch added

Hopefully a final fix :)

comment:4 Changed 12 years ago by James Bennett

Resolution: fixed
Status: reopenedclosed

(In [3935]) Fixed #1113, thanks to Jacob for spotting the deeper bug

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