django-sitetree how to migrate data to production server

437 Views Asked by At

I'm using south to migrate schemes to production. Also I'm using the django-sitetree module to show the menu in my site.

There is no problem with schema migration by using commands:

./manage.py schemamigration myApp --freeze sitetree --auto
./manage.py migrate myApp

However when I'm trying to migrate the sitetree data by command:

./manage.py datamigration myApp "new_version" --freeze sitetree

it doesn't generate any of created sitetree elements.

1

There are 1 best solutions below

1
On BEST ANSWER

Ok, after some research and thanks to this sources: Altering database tables in Django and Fixtures and initial data blog, it seems that the better way to pass the menu data by using initial_data.json file with fixtures.

  1. Create "fixtures" folder inside your App folder.

  2. Run ./manage.py dumpdata --format=json --indent=4 sitetree > APP_PATH/fixtures/initial_data.json You can add more app to the command if you wish their data to be migrated to other environments.

  3. The saved data to fixtures/initial_data.json will be always inserted/replaced by running ./manage.py syncdb Remember that the data will be replaced if it already exists in DB, it means that you should not dump the dynamic data.

There is the other way to migrate the sitetree using sitetree management command

# Dump...
python manage.py sitetreedump > treedump.json
# Restore...
python manage.py sitetreeload --mode=replace treedump.json

Thank you to idle-sign for this link