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

Fixed #36326 -- Added CompositePrimaryKey support in QuerySet.raw().

Signed-off-by: SaJH <wogur981208@gmail.com>
This commit is contained in:
SaJH
2025-04-15 03:06:49 +09:00
committed by Sarah Boyce
parent d755a98b84
commit 1831f7733d
3 changed files with 21 additions and 2 deletions

View File

@@ -165,7 +165,9 @@ class RawModelIterable(BaseIterable):
annotation_fields,
) = self.queryset.resolve_model_init_order()
model_cls = self.queryset.model
if model_cls._meta.pk.attname not in model_init_names:
if any(
f.attname not in model_init_names for f in model_cls._meta.pk_fields
):
raise exceptions.FieldDoesNotExist(
"Raw query must include the primary key"
)