2012-09-13

Initial data for Django database

Please refer to https://docs.djangoproject.com/en/dev/howto/initial-data/#initial-sql

Django use fixtures as data output/input format. Here is an example:

[
{
"pk": 2,
"model": "auth.group",
"fields": {
"name": "APK Reviewer",
"permissions": [22]
}
}
]
Method to Export models from Django:
python manage.py dumpdata [modelname] > [exportfile.json]
You can also use this command to display models schema without database client:
python manage.py sql [modelname]
Method to Import models into Django:
python manage.py loaddata --verbosity=2 [importfile.json]

No comments: