Opened 8 years ago

Closed 8 years ago

#4699 closed (fixed)

list_filter = ('name',) doesn't work in newforms-admin

Reported by: eisoab@… Owned by: jkocherhans
Component: contrib.admin Version: newforms-admin
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The following simple model gives me an error message if the list_filter
line is present in the class CompoundOptions.
If it's not present and any of the other out-comments lines are, the admin
site works as expected.

# Create your models here.

from django.db import models
class Compound(models.Model):
    name = models.CharField(maxlength=20,unique=True,null=True)
from django.contrib import admin
class CompoundOptions(admin.ModelAdmin):
    #list_select_related = True
    #list_display = ('name',)
    list_filter = ('name',)
    #list_per_page = 25,CompoundOptions)


I get the following error message:

AttributeError at /xxx/admin/qqq/compound/
'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.3/site-packages/django/contrib/admin/ in __init__, line 161
Python Executable: 	/usr/bin/python
Python Version: 	2.3.4

Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/django/core/handlers/" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/" in root
  123. return self.model_page(request, *url.split('/', 2))
File "/usr/lib/python2.3/site-packages/django/contrib/admin/" in model_page
  140. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/" in __call__
  210. return self.changelist_view(request)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/" in changelist_view
  589. self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/views/" in __init__
  263. self.filter_specs, self.has_filters = self.get_filters(request)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/views/" in get_filters
  271. spec = FilterSpec.create(f, request, self.params, self.model)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/" in create
  25. return factory(f, request, params, model)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/" in __init__
  161. self.lookup_choices = model._meta.admin.manager.distinct().order_by(

  AttributeError at /zbdb/admin/qqq/compound/
  'NoneType' object has no attribute 'manager'

If you nee more info please let me know.


Change History (8)

comment:1 Changed 8 years ago by jkocherhans

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Note to self: this is almost certainly a side-effect of #4587

comment:2 Changed 8 years ago by jkocherhans

  • Owner changed from nobody to jkocherhans
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 8 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [6103]) newforms-admin: Fixed #4699. list_filter broken in admin for strings.

comment:4 Changed 8 years ago by jkocherhans

  • Resolution fixed deleted
  • Status changed from closed to reopened

This needs to use the ModelAdmin's queryset if there is one, not the default. Oops.

comment:5 Changed 8 years ago by jkocherhans

  • Status changed from reopened to new

comment:6 Changed 8 years ago by jkocherhans

#4759 and #3973 are duplicates.

comment:7 Changed 8 years ago by jkocherhans

Yuck. This is going to require a lot of changes in django.contrib.admin.view.main.ChangeList, which needs to be refactored anyhow. I'm going to leave [6103] in place until that happens.

comment:8 Changed 8 years ago by jkocherhans

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

(In [6216]) newforms-admin: Fixed #4699. Really this time. AllValuesFilterSpec uses the ModelAdmin's queryset method instead of the model's deafult queryset.

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