Opened 18 years ago
Closed 18 years ago
#4699 closed (fixed)
list_filter = ('name',) doesn't work in newforms-admin
| Reported by: | 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: | no | UI/UX: | no | 
Description
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):
    '''
        Compounds
    '''
    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
    
admin.site.register(Compound,CompoundOptions)
---
I get the following error message:
AttributeError at /xxx/admin/qqq/compound/
'NoneType' object has no attribute 'manager'
Request Method: 	GET
Request URL: 	https://fwnc7122.wks.gorlaeus.net/zbdb/admin/qqq/compound/
Exception Type: 	AttributeError
Exception Value: 	'NoneType' object has no attribute 'manager'
Exception Location: 	/usr/lib/python2.3/site-packages/django/contrib/admin/filterspecs.py 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/base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/sites.py" in root
  123. return self.model_page(request, *url.split('/', 2))
File "/usr/lib/python2.3/site-packages/django/contrib/admin/sites.py" in model_page
  140. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/options.py" in __call__
  210. return self.changelist_view(request)
File "/usr/lib/python2.3/site-packages/django/contrib/admin/options.py" 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/main.py" in __init__
  263. self.filter_specs, self.has_filters = self.get_filters(request)
File "/usr/lib/python2.3/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.3/site-packages/django/contrib/admin/filterspecs.py" in create
  25. return factory(f, request, params, model)
File "/usr/lib/python2.3/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 /zbdb/admin/qqq/compound/
  'NoneType' object has no attribute 'manager'
If you nee more info please let me know. 
Eiso 
Change History (8)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
| Owner: | changed from to | 
|---|---|
| Status: | new → assigned | 
| Triage Stage: | Unreviewed → Accepted | 
comment:3 by , 18 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
comment:4 by , 18 years ago
| Resolution: | fixed | 
|---|---|
| Status: | closed → reopened | 
This needs to use the ModelAdmin's queryset if there is one, not the default. Oops.
comment:5 by , 18 years ago
| Status: | reopened → new | 
|---|
comment:7 by , 18 years ago
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 by , 18 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
Note to self: this is almost certainly a side-effect of #4587