what is the best way to write a python script (not to run within a Django server app) making use of Django settings, models, utilities etc and hence being able to operate on an app database from, say, a batch process?
EDIT
I need to use this within another server to make rather complex operations on the database, so solutions like custom AppCommands or invoking a Djando page won’t really work
Thanks
One way to do this is to create your own management command. Then you can do something like this from e.g. your crontab:
Another way is to make sure Django, your Django project and, when required, third party apps are on your PYTHONPATH. Then you can access the database and ORM using a few lines of code:
Now you can e.g. do things like this: