Django

Code

Ticket #1113 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

OneToOneField with limit_choices_to breaks ChangeList

Reported by: Nebojša Đorđević - nesh <nesh@studioquattro.co.yu> Assigned to: adrian
Milestone: Component: Admin interface
Version: Keywords:
Cc: nesh@studioquattro.co.yu Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

1113.patch (1.5 kB) - added by jacob on 10/25/06 14:40:37.
Hopefully a final fix :)

Change History

08/11/06 14:27:38 changed 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.

08/12/06 22:00:37 changed by James Bennett <ubernostrum@gmail.com>

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in [3576]

10/25/06 14:40:08 changed by jacob

  • status changed from closed to reopened.
  • resolution deleted.

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

10/25/06 14:40:37 changed by jacob

  • attachment 1113.patch added.

Hopefully a final fix :)

10/25/06 15:25:54 changed by ubernostrum

  • status changed from reopened to closed.
  • resolution set to fixed.

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


Add/Change #1113 (OneToOneField with limit_choices_to breaks ChangeList)




Change Properties
Action