2

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

Shreyash mishra
  • 738
  • 1
  • 7
  • 30
  • 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 Answers1

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