Code

Opened 7 years ago

Closed 7 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: UI/UX:

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@… 7 years ago.

Download all attachments as: .zip

Change History (6)

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from AttributeError for some models to AttributeError for some models in the admin (newforms-admin branche)

Changed 7 years ago by philippe.raoult@…

comment:2 Changed 7 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 7 years ago by adrian

  • Version changed from new-admin to SVN

comment:4 Changed 7 years ago by adrian

  • Version changed from SVN to newforms-admin

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

comment:5 Changed 7 years ago by jkocherhans

  • Resolution set to duplicate
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.