#19746: Allowing serialization without 'pk' --------------------------------------+-------------------- Reporter: rafallo | Owner: nobody Type: New feature | Status: new Component: Core (Serialization) | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 1 Easy pickings: 0 | UI/UX: 0 --------------------------------------+-------------------- Currently, if I want to use python serializer to deserialize data, I have to put 'pk' or proper pk.attname value in object in object_list. I suggest to allow deserialize object without 'pk' attribute and allow DB to create 'pk' value.
{{{ diff --git django/core/serializers/python.py django/core/serializers/python.py index 5e07e2a..cdfac50 100644 --- django/core/serializers/python.py +++ django/core/serializers/python.py @@ -88,7 +88,7 @@ def Deserializer(object_list, **options): for d in object_list: # Look up the model and starting build a dict of data for it. Model = _get_model(d["model"]) - data = {Model._meta.pk.attname: Model._meta.pk.to_python(d["pk"])} + data = {Model._meta.pk.attname: Model._meta.pk.to_python(d.get("pk", None))} m2m_data = {} model_fields = Model._meta.get_all_field_names() }}} Do I have to write proper documentation? -- Ticket URL: <https://code.djangoproject.com/ticket/19746> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.