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:
Brian King 2015-06-05 12:40:51 +01:00 committed by Tim Graham
parent 841a87785a
commit bfb5b7150f
4 changed files with 119 additions and 1 deletions

View file

@ -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')