Opened 19 years ago

Closed 18 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

Description

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/main.py (from line 229):

        if opts.one_to_one_field:
            lookup_params.update(opts.one_to_one_field.rel.limit_choices_to)

Bug or feature? :)

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

comment:1 by James Bennett, 18 years ago

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 by James Bennett <ubernostrum@…>, 18 years ago

Resolution: fixed
Status: newclosed

Fixed in [3576]

comment:3 by Jacob, 18 years ago

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 (http://code.djangoproject.com/browser/django/branches/0.90-bugfixes/django/contrib/admin/views/main.py#L82) 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...

by Jacob, 18 years ago

Attachment: 1113.patch added

Hopefully a final fix :)

comment:4 by James Bennett, 18 years ago

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