Last active
March 31, 2022 04:22
-
-
Save stroykova/210f48db01f0604518da to your computer and use it in GitHub Desktop.
How to serialize and deserialize model objects in django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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