Opened 9 years ago

Closed 9 years ago

#1113 closed defect (fixed)

OneToOneField with limit_choices_to breaks ChangeList

Reported by: Nebojša Đorđević - nesh <nesh@…> Owned by: adrian
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: UI/UX:

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 9 years ago.
Hopefully a final fix :)

Download all attachments as: .zip

Change History (5)

comment:1 Changed 9 years ago by ubernostrum

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

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

Fixed in [3576]

comment:3 Changed 9 years ago by jacob

  • Resolution fixed deleted
  • Status changed from closed to reopened

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...

Changed 9 years ago by jacob

Hopefully a final fix :)

comment:4 Changed 9 years ago by ubernostrum

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

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

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