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

Fixed #11707 - limit_choices_to on a ForeignKey can render duplicate options in formfield

Thanks to Chris Wesseling for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15607 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant
2011-02-21 14:03:59 +00:00
parent 470d9b2602
commit 6902824ac2
3 changed files with 24 additions and 2 deletions

View File

@@ -29,6 +29,11 @@ class Bar(models.Model):
b = models.CharField(max_length=10)
a = models.ForeignKey(Foo, default=get_foo)
class Baz(models.Model):
a = models.CharField(max_length=5)
#Only Foos related to Bars starting with 'a'
foo = models.ForeignKey(Foo, limit_choices_to=models.Q(bar__b__startswith='a'))
class Whiz(models.Model):
CHOICES = (
('Group 1', (