Login

Snippets by dakrauth

Snippet List

Command Line Script Launcher

I often write short test or development scripts that are intended as one-offs. I typically want to execute these scripts from the command line but am always forgetting the necessary steps to set up the Django environment [as described here][bennett]. This snippet allows you execute arbitrary Python scripts from the command line with the context of a given project: python manage.py execfile /path/to/some/script.py Add the code to a file named `execfile.py` within the `management/commands` directory of one of your apps ([see here][ref] for details). [ref]: http://www.djangoproject.com/documentation/django-admin/#customized-actions "Customized Actions" [bennett]: http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ "Standalone Django Scripts"

  • script
  • management
  • execfile
Read More

dakrauth has posted 1 snippet.