Opened 13 years ago

Last modified 13 years ago

#16714 closed Bug

Can't list_filter across a relationship on a SmallIntegerField — at Initial Version

Reported by: Alex Ogier Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal 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

If you have a SmallIntegerField on a model that is related via a foreign key then you can't use that field as an option in list_filter. Doing so gives you the correct distinct options in the list page sidebar, but if you try to select any of them you receive a 302 redirect to /?e=1, as if you had used an unexpected query-string parameter.

Here's a small example to try yourself:

# models.py

from django.db import models

class Rel(models.Model):
    year = models.SmallIntegerField(default=2010)

class Src(models.Model):
    rel = models.ForeignKey(Rel)

# admin.py

from models import Rel, Src
from django.contrib import admin

class RelAdmin(admin.ModelAdmin):
    model = Rel
    list_filter = ('year',)
admin.site.register(Rel, RelAdmin)

class SrcAdmin(admin.ModelAdmin):
    model = Src
    list_filter = ('rel__year',)
admin.site.register(Src, SrcAdmin)

I'm running Django 1.3, MySQL 5.5, on Arch Linux.

Change History (0)

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