user1788104
user1788104

Reputation: 81

export data from Django database

how to copy records from one database to another django ?

I tried for the first database

python manage.py dumpdata material - indent = 1

material is the directory database after ?

material.json ?

do I copy this file somewhere? in the second database ?

Upvotes: 6

Views: 5381

Answers (1)

CJ4
CJ4

Reputation: 2535

You can use this command to dump the data to a json file:

python manage.py dumpdata material --indent=1 > my_dir/material.json

And then this command to load it into the database:

python manage.py loaddata my_dir/material.json

Upvotes: 12

Related Questions