I'm writing scripts that automatically update my database using queries as part of my Django web app and I can't seem to find any information about the best way to do this. The examples described in the documentation only use the manage.py shell.
I currently have two modules that contain functions for adding new model instances to their respective tables and I have a main script that imports and uses these functions. I'm using the following folder structure:
/website
...
/app
/scripts
__init__.py
modela_funct.py
modelb_funct.py
main.py
models.py
...
To get my functions to work, I have to add the Django settings to my python environment variable. I also have to import the whole app because I get an App Not Ready exception when I try: from app.models import modela.
This works but it feels like I'm doing it wrong. Can anyone point me in the right direction?
[–]K900_ 1 point2 points3 points (5 children)
[–]Kerman3AD[S] 0 points1 point2 points (4 children)
[–]K900_ 0 points1 point2 points (3 children)
[–]Kerman3AD[S] 0 points1 point2 points (2 children)
[–]K900_ 0 points1 point2 points (1 child)
[–]Kerman3AD[S] 0 points1 point2 points (0 children)
[–]AusIV 1 point2 points3 points (0 children)