Opened 18 years ago

Closed 17 years ago

#3973 closed (duplicate)

AttributeError for some models in the admin (newforms-admin branche)

Reported by: Baptiste <baptiste.goupil@…> 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)

filter_allvalue_fix.diff (690 bytes ) - added by philippe.raoult@… 18 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Baptiste <baptiste.goupil@…>, 18 years ago

Summary: AttributeError for some modelsAttributeError for some models in the admin (newforms-admin branche)

by philippe.raoult@…, 18 years ago

Attachment: filter_allvalue_fix.diff added

comment:2 by philippe.raoult@…, 18 years ago

Has patch: set

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.

comment:3 by Adrian Holovaty, 17 years ago

Version: new-adminSVN

comment:4 by Adrian Holovaty, 17 years ago

Version: SVNnewforms-admin

I think this patch is wrong. It shouldn't use model._default_manager -- it should use the ModelOption's manager.

comment:5 by jkocherhans, 17 years ago

Resolution: duplicate
Status: newclosed

I already fixed this, the wrong way, in [6103] in response to #4699. I'm re-opening that ticket until I fixed it the right way. #4759 is also a duplicate.

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