diff options
| author | Bendeguz Csirmaz <csirmazbendeguz@gmail.com> | 2024-04-07 10:32:16 +0800 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-11-29 11:23:04 +0100 |
| commit | 978aae4334fa71ba78a3e94408f0f3aebde8d07c (patch) | |
| tree | dd1cc322769441a3dd28b952ce52e07c3f72f90a /django/core/serializers/python.py | |
| parent | 86661f2449fb0903f72b3522c68e146934013377 (diff) | |
Fixed #373 -- Added CompositePrimaryKey.
Thanks Lily Foote and Simon Charette for reviews and mentoring
this Google Summer of Code 2024 project.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Co-authored-by: Lily Foote <code@lilyf.org>
Diffstat (limited to 'django/core/serializers/python.py')
| -rw-r--r-- | django/core/serializers/python.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py index 46ef9f0771..57edebbb70 100644 --- a/django/core/serializers/python.py +++ b/django/core/serializers/python.py @@ -7,6 +7,7 @@ other serializers. from django.apps import apps from django.core.serializers import base from django.db import DEFAULT_DB_ALIAS, models +from django.db.models import CompositePrimaryKey from django.utils.encoding import is_protected_type @@ -39,6 +40,8 @@ class Serializer(base.Serializer): return data def _value_from_field(self, obj, field): + if isinstance(field, CompositePrimaryKey): + return [self._value_from_field(obj, f) for f in field] value = field.value_from_object(obj) # Protected types (i.e., primitives like None, numbers, dates, # and Decimals) are passed through as is. All other values are |
