I have a script which uses the Django ORM features, amongst other external libraries, that I want to run outside of Django (that is, executed from the command-line).
Edi
All you need is importable settings and properly set python path. In the most raw form this can be done by setting up appropriate environment variables, like:
$ DJANGO_SETTINGS_MODULE=myproject.settings PYTHONPATH=$HOME/djangoprojects python myscript.py
There are other ways, like calling settings.configure()
and already mentioned setup_environ()
described by James Bennett in some blog post.