mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #30343 -- Fixed prefetch_related() for GenericForeignKey when PK of related field is UUIDField.
This commit is contained in:
@@ -172,6 +172,11 @@ class TaggedItem(models.Model):
|
||||
return self.tag
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=20)
|
||||
|
||||
|
||||
class Bookmark(models.Model):
|
||||
url = models.URLField()
|
||||
tags = GenericRelation(TaggedItem, related_query_name='bookmarks')
|
||||
@@ -188,9 +193,12 @@ class Comment(models.Model):
|
||||
comment = models.TextField()
|
||||
|
||||
# Content-object field
|
||||
content_type = models.ForeignKey(ContentType, models.CASCADE)
|
||||
content_type = models.ForeignKey(ContentType, models.CASCADE, null=True)
|
||||
object_pk = models.TextField()
|
||||
content_object = GenericForeignKey(ct_field="content_type", fk_field="object_pk")
|
||||
content_type_uuid = models.ForeignKey(ContentType, models.CASCADE, related_name='comments', null=True)
|
||||
object_pk_uuid = models.TextField()
|
||||
content_object_uuid = GenericForeignKey(ct_field='content_type_uuid', fk_field='object_pk_uuid')
|
||||
|
||||
class Meta:
|
||||
ordering = ['id']
|
||||
|
||||
Reference in New Issue
Block a user