Skip to content

Instantly share code, notes, and snippets.

@marcosricardoss
Last active December 29, 2021 17:17
Show Gist options
  • Save marcosricardoss/f85e3319c7a9a5d2e05e2b0d701b215b to your computer and use it in GitHub Desktop.
Save marcosricardoss/f85e3319c7a9a5d2e05e2b0d701b215b to your computer and use it in GitHub Desktop.
Django dump data for a single model
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