Opened 19 years ago
Closed 18 years ago
#1113 closed defect (fixed)
OneToOneField with limit_choices_to breaks ChangeList
Reported by: | 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)
Change History (5)
comment:1 by , 18 years ago
comment:3 by , 18 years ago
Resolution: | fixed |
---|---|
Status: | closed → 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...
comment:4 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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.