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

Fixed #29010, Fixed #29138 -- Added limit_choices_to and to_field support to autocomplete fields.

* Fixed #29010 -- Added limit_choices_to support to autocomplete fields.
* Fixed #29138 -- Allowed autocomplete fields to target a custom
  to_field rather than the PK.
This commit is contained in:
Johannes Maron
2021-01-12 11:37:38 +01:00
committed by GitHub
parent ba3fb2e4d0
commit 3071660acf
11 changed files with 200 additions and 60 deletions

View File

@@ -19,6 +19,7 @@ class Member(models.Model):
class Band(models.Model):
uuid = models.UUIDField(unique=True, default=uuid.uuid4)
name = models.CharField(max_length=100)
style = models.CharField(max_length=20)
members = models.ManyToManyField(Member)
@@ -36,7 +37,7 @@ class UnsafeLimitChoicesTo(models.Model):
class Album(models.Model):
band = models.ForeignKey(Band, models.CASCADE)
band = models.ForeignKey(Band, models.CASCADE, to_field='uuid')
featuring = models.ManyToManyField(Band, related_name='featured')
name = models.CharField(max_length=100)
cover_art = models.FileField(upload_to='albums')