Opened 17 years ago

Closed 17 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: 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 jkocherhans, 17 years ago

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

comment:2 by jkocherhans, 17 years ago

Owner: changed from nobody to jkocherhans
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:3 by jkocherhans, 17 years ago

Resolution: fixed
Status: assignedclosed

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

comment:4 by jkocherhans, 17 years ago

Resolution: fixed
Status: closedreopened

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

comment:5 by jkocherhans, 17 years ago

Status: reopenednew

comment:6 by jkocherhans, 17 years ago

#4759 and #3973 are duplicates.

comment:7 by jkocherhans, 17 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 jkocherhans, 17 years ago

Resolution: fixed
Status: newclosed

(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