Last active
December 29, 2021 17:17
-
-
Save marcosricardoss/f85e3319c7a9a5d2e05e2b0d701b215b to your computer and use it in GitHub Desktop.
Django dump data for a single model
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 | |
from myproject.myapp import models | |
data = serializers.serialize("json", models.MyModel.objects.all()) | |
out = open("dump.json", "w") | |
out.write(data) | |
out.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment