mirror of
https://github.com/django/django.git
synced 2025-11-03 05:13:23 +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:
parent
470d9b2602
commit
6902824ac2
3 changed files with 24 additions and 2 deletions
|
|
@ -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', (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue