#34620: Serialization of m2m relation fails with custom manager using
select_related
--------------------------------------+------------------------------------
Reporter: Martin Svoboda | Owner: nobody
Type: Bug | Status: new
Component: Core (Serialization) | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Mariusz Felisiak):
Maybe we could clear `select_related()`:
{{{#!diff
diff --git a/django/core/serializers/python.py
b/django/core/serializers/python.py
index 36048601af..5c6e1c2689 100644
--- a/django/core/serializers/python.py
+++ b/django/core/serializers/python.py
@@ -79,7 +79,7 @@ class Serializer(base.Serializer):
return self._value_from_field(value, value._meta.pk)
def queryset_iterator(obj, field):
- return getattr(obj, field.name).only("pk").iterator()
+ return getattr(obj,
field.name).select_related().only("pk").iterator()
m2m_iter = getattr(obj, "_prefetched_objects_cache", {}).get(
field.name,
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34620#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701887ba60c68-bc26a823-d156-4bdd-ae8c-2dc8884356e0-000000%40eu-central-1.amazonses.com.