我有这些模型
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
和这个管理员
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)
当我尝试访问list_filter' course__directory__sector' (http://localhost:8000/admin/myapp/team/?course__directory__sector__id__exact=1)在django 1.9中。这直到django 1.7。有人能告诉我如何解决这个问题吗?