Order now and save 40%! But wait! Call in the next 15 minutes and we’ll double your offer, FOR FREE!
So this is the safe way to provide initial SQL data on a syncdb, in the form a .sql file in your app:
But I find it a pain in the ass.
I use the initial_data fixture to load data on syncdb. I find it extremely easy to do and requires no setup. You could literally set this up in 3 seconds. one command sounds too good to be true.
Its not very documented so I’ll post it here. I see little references to initial_data and dumpdata here and there, but yeah:
<code>python manage.py dumpdata > initial_data.json</code>
dumpdata dumps all of your models (using your default manager) in json format. check the dumpdata help for other args like –indent=Num to make it readable.
Anyways, that single command will dump the data to initial_data.json and it will be ready to go.
The only problem with this approach is if you modify your tables to have new non nullable fields this will throw an error. But if you are done with an app and it has basic categories, by all means, python manage.py dumpdata app > initial_data.json.