Opened 12 years ago

Closed 11 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


Here is the exception :

AttributeError at /admin/blog/article/
'NoneType' object has no attribute 'manager'
Request Method: 	GET
Request URL:
Exception Type: 	AttributeError
Exception Value: 	'NoneType' object has no attribute 'manager'
Exception Location: 	/usr/lib/python2.4/site-packages/django/contrib/admin/ 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/" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/" in root
  123. return self.model_page(request, *url.split('/', 2))
File "/usr/lib/python2.4/site-packages/django/contrib/admin/" in model_page
  140. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/" in __call__
  136. return self.changelist_view(request)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/" 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/" in __init__
  263. self.filter_specs, self.has_filters = self.get_filters(request)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/" in get_filters
  271. spec = FilterSpec.create(f, request, self.params, self.model)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/" in create
  25. return factory(f, request, params, model)
File "/usr/lib/python2.4/site-packages/django/contrib/admin/" in __init__
  161. self.lookup_choices = model._meta.admin.manager.distinct().order_by(

  AttributeError at /admin/blog/article/
  'NoneType' object has no attribute 'manager'

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

comment:1 Changed 12 years ago by Baptiste <baptiste.goupil@…>

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

Changed 12 years ago by philippe.raoult@…

Attachment: filter_allvalue_fix.diff added

comment:2 Changed 12 years ago by philippe.raoult@…

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 Changed 12 years ago by Adrian Holovaty

Version: new-adminSVN

comment:4 Changed 11 years ago by Adrian Holovaty

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 Changed 11 years ago by jkocherhans

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