Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 783
user1788104 Avatar asked Mar 23 '23 09:03

user1788104


1 Answers

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
like image 156
CJ4 Avatar answered Apr 05 '23 23:04

CJ4