I’m using a third party application in my Django project (photologue) and I wonder if it is possible to provide initial sql data for this application the same way I do with my own.
As the application is installed in the central python site package, and I don’t want/can create an sql file there (and doubt that it will work that way). I tried adding one in my Django project and creating an sql folder with the required sql files but without success.
So my question is this:
- Is it possible to provide initial sql data for third party applications
- Is there any way (hook) to do so without passing by a customization of the manager.py script
Yes, you can provide initial SQL data or fixtures:
The
sqlsolution will work only for syncdb upon creation of models of the app containing the folder.For other apps You might wanna take the fixtures route, as you can specify there what ever models you want. The you can either load them with
manage.py loaddatacommand, or, if you’ll name the fileinitial_data.[xml/yaml/json](extension depending on format), it will be loaded on syncdb, just note the warning that comes with it:https://docs.djangoproject.com/en/dev/howto/initial-data/#automatically-loading-initial-data-fixtures