#423 closed defect (fixed)
Admin filters broken with [549]
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I changed my models over to the new syntax and svn up'd django this morning. Everything seems to work fine except for filters in the admin interface. I have a ForeignKey realtion called 'site'... the admin interface generates a url like:
http://127.0.0.1:8000/childabuse/data/patients/?site__exact=4
Which results in the traceback below. If I manually type in the url:
http://127.0.0.1:8000/childabuse/data/patients/?site__id__exact=4
It works as expected. I'm not sure if this is a problem with the admin interface, or the db api. According to the new db api docs, it looks like a problem with the admin interface though.
Traceback (most recent call last): File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py", line 64, in get_response response = callback(request, **param_dict) File "/usr/local/lib/python2.4/site-packages/django/views/admin/main.py", line 177, in change_list result_count = p.hits File "/usr/local/lib/python2.4/site-packages/django/core/paginator.py", line 67, in _get_hits self._hits = getattr(self.module, self.count_method)(**order_args) File "/usr/local/lib/python2.4/site-packages/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1127, in function_get_count _, sql, params = function_get_sql_clause(opts, **kwargs) File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1299, in function_get_sql_clause tables2, join_where2, where2, params2, _ = _parse_lookup(kwargs.items(), opts) File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1228, in _parse_lookup _throw_bad_kwarg_error(kwarg) File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1178, in _throw_bad_kwarg_error raise TypeError, "got unexpected keyword argument '%s'" % kwarg TypeError: got unexpected keyword argument 'site__exact'
I haven't tested the code below, but it should show my point.
The link for each filter item is like:
http://127.0.0.1:8000/admin/appname/bars/?foo__exact=1
http://127.0.0.1:8000/admin/appname/bars/?foo__exact=2
etc, but the page for this links don't work. (See the taceback above.) These work however:
http://127.0.0.1:8000/admin/appname/bars/?foo__id__exact=1
http://127.0.0.1:8000/admin/appname/bars/?foo__id__exact=2
Despite reading the docs, I'm not sure what the expected behavior is. If the second set set of links should work, here's a patch to fix the admin interface. If the first set of links should work, then I can't figure out how to fix it at first glance. It seems to me, that with the new model syntax, both should work. Hopefully this is a little clearer than my initial report.