1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #3096 -- Make admin list_filters respect limit_choices_to.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey
2008-10-21 19:03:21 +00:00
parent 49ef21d9ea
commit ae43d11838
4 changed files with 52 additions and 4 deletions

View File

@@ -74,7 +74,24 @@ class ModelWithStringPrimaryKey(models.Model):
def __unicode__(self):
return self.id
class Color(models.Model):
value = models.CharField(max_length=10)
warm = models.BooleanField()
def __unicode__(self):
return self.value
class Thing(models.Model):
title = models.CharField(max_length=20)
color = models.ForeignKey(Color, limit_choices_to={'warm': True})
def __unicode__(self):
return self.title
class ThingAdmin(admin.ModelAdmin):
list_filter = ('color',)
admin.site.register(Article, ArticleAdmin)
admin.site.register(CustomArticle, CustomArticleAdmin)
admin.site.register(Section, inlines=[ArticleInline])
admin.site.register(ModelWithStringPrimaryKey)
admin.site.register(Color)
admin.site.register(Thing, ThingAdmin)