mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #24912 -- Fixed prefetch_related failure for UUIDField primary keys
This resolves a problem on databases besides PostgreSQL when using prefetch_related with a source model that uses a UUID primary key.
This commit is contained in:
parent
841a87785a
commit
bfb5b7150f
4 changed files with 119 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import uuid
|
||||
|
||||
from django.contrib.contenttypes.fields import (
|
||||
GenericForeignKey, GenericRelation,
|
||||
)
|
||||
|
@ -257,3 +259,18 @@ class Author2(models.Model):
|
|||
|
||||
class Meta:
|
||||
ordering = ['id']
|
||||
|
||||
|
||||
# Models for many-to-many with UUID pk test:
|
||||
|
||||
class Pet(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=20)
|
||||
people = models.ManyToManyField(Person, related_name='pets')
|
||||
|
||||
|
||||
class Flea(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
current_room = models.ForeignKey(Room, related_name='fleas', null=True)
|
||||
pets_visited = models.ManyToManyField(Pet, related_name='fleas_hosted')
|
||||
people_visited = models.ManyToManyField(Person, related_name='fleas_hosted')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue