I have Django app, one is in local machine and other is in production server after deploying in production server i see i lost all my local data lost so I want to know how I can copy all my data from db and paste into production server so is there any way please share how to do it
Asked
Active
Viewed 789 times
2
-
If you use SQLite on both (which I do not recommend), you can simply copy the DB file over. If you use a SQL server on the production server, you can use fixtures: https://docs.djangoproject.com/en/3.2/howto/initial-data/. – physicalattraction Sep 23 '21 at 11:48
1 Answers
3
Dump db on local machine:
python3 manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 4 > db.json
Load db on production server:
python3 manage.py loaddata db.json

kamran890
- 762
- 4
- 7
-
Thank you, but I am wondering what If i have to copy my production data into in local machine is there any way to do that – Shreyash mishra Sep 23 '21 at 17:47
-
In the same way, you can dump db on production server and load it on local machine using same above commands. – kamran890 Sep 23 '21 at 17:52
-
then how i can download my db file form heroku production server – Shreyash mishra Sep 23 '21 at 18:02