Stand-alone Django script

Sometimes we need run a stand alone python script which uses the models of the Django project, let’s assume we want to run a python script in a cron job which uses our Django’s models and the setup is all within confide environment created with virtualenv. In order to achieve this the script needs to know several things. The first step is to add Django settings module to the environment inside the stand-alone script, this indicates the path to the Django projects and it’s ‘settings’. Then we need to activate the virtual environment within the script.

Read More (External)