diff options
| author | SaJH <wogur981208@gmail.com> | 2025-04-15 03:06:49 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-04-17 17:23:06 +0200 |
| commit | 1831f7733d3ef03d1ca7fac3e8d9f4c5e3e3375e (patch) | |
| tree | 8afb3f55f29eb7f3d3b1db92d36c19dfbf78a1fb /django | |
| parent | d755a98b8438c10f3cff61303ceb1fe16d414e9b (diff) | |
Fixed #36326 -- Added CompositePrimaryKey support in QuerySet.raw().
Signed-off-by: SaJH <wogur981208@gmail.com>
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index e019dd6db9..915acb629a 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -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" ) |
