Opened 19 years ago
Closed 18 years ago
#3973 closed (duplicate)
AttributeError for some models in the admin (newforms-admin branche)
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | contrib.admin | Version: | newforms-admin |
| Severity: | Keywords: | attributeerror list_filter | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Here is the exception :
AttributeError at /admin/blog/article/ 'NoneType' object has no attribute 'manager' Request Method: GET Request URL: http://127.0.0.1:8000/admin/blog/article/ Exception Type: AttributeError Exception Value: 'NoneType' object has no attribute 'manager' Exception Location: /usr/lib/python2.4/site-packages/django/contrib/admin/filterspecs.py in __init__, line 161
I have located the error : it comes when I add some fields to
list_filter = []
(in the admin.ModelAdmin class)
Some (DateTime, ForeignKey, Boolean) are okay, but if I add a CharField, a SlugField or even a TextField to the list_filter, I get the exception.
And here is the Traceback :
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py" in root
123. return self.model_page(request, *url.split('/', 2))
File "/usr/lib/python2.4/site-packages/django/contrib/admin/sites.py" in model_page
140. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/options.py" in __call__
136. return self.changelist_view(request)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/options.py" in changelist_view
486. self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in __init__
263. self.filter_specs, self.has_filters = self.get_filters(request)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in get_filters
271. spec = FilterSpec.create(f, request, self.params, self.model)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/filterspecs.py" in create
25. return factory(f, request, params, model)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/filterspecs.py" in __init__
161. self.lookup_choices = model._meta.admin.manager.distinct().order_by(f.name).values(f.name)
AttributeError at /admin/blog/article/
'NoneType' object has no attribute 'manager'
Attachments (1)
Change History (6)
comment:1 by , 19 years ago
| Summary: | AttributeError for some models → AttributeError for some models in the admin (newforms-admin branche) |
|---|
by , 19 years ago
| Attachment: | filter_allvalue_fix.diff added |
|---|
comment:2 by , 19 years ago
| Has patch: | set |
|---|
comment:3 by , 18 years ago
| Version: | new-admin → SVN |
|---|
comment:4 by , 18 years ago
| Version: | SVN → newforms-admin |
|---|
I think this patch is wrong. It shouldn't use model._default_manager -- it should use the ModelOption's manager.
comment:5 by , 18 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
this patch against newforms-admin fixes the bug. It looks that the default filter was been using an older API and hadn't been updated.