当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Django 1.9 list_filter

问题描述:

I have these models

class Team(models.Model):

description = models.CharField('Description', max_length=500)

def __str__(self):

return self.description

class Course(models.Model):

description = models.CharField('Description', max_length=500)

directory = models.ForeignKey('myapp.Directory', null=True, verbose_name='Directory')

groups = models.ManyToManyField('myapp.Team', through='myapp.TeamCourse')

def __str__(self):

return self.description

class TeamCourse(models.Model):

course = models.ForeignKey('myapp.Course')

team = models.ForeignKey('myapp.Team')

def __str__(self):

return self.team.description

class Directory(models.Model):

description = models.CharField('Description', max_length=500)

sector = models.ForeignKey('myapp.Sector')

def __str__(self):

return self.description

class Sector(models.Model):

description = models.CharField('Description', max_length=500)

def __str__(self):

return self.description

and this admin

class TeamAdmin(admin.ModelAdmin):

list_display = ('id', 'description')

list_filter = ('course', 'course__directory', 'course__directory__sector')

search_fields = ('id', 'course',)

list_display_icons = True

list_per_page = 15

export_to_xls = True

admin.site.register(Team, TeamAdmin)

The problem occurs when I try to access the list_filter 'course__directory__sector' (http://localhost:8000/admin/myapp/team/?course__directory__sector__id__exact=1) in the django 1.9. This worked until django 1.7. Can someone tell me how to fix this?

分享给朋友:
您可能感兴趣的文章:
随机阅读: