Skip to content

Instantly share code, notes, and snippets.

@stroykova
Last active March 31, 2022 04:22
Show Gist options
  • Save stroykova/210f48db01f0604518da to your computer and use it in GitHub Desktop.
Save stroykova/210f48db01f0604518da to your computer and use it in GitHub Desktop.
How to serialize and deserialize model objects in django
from django.core import serializers
data = serializers.serialize('json', [my_model_object])
for copy in serializers.deserialize("json", data):
copy.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment