Snippet List
To make all scripts relocatable.
The layout of my project is:
/some/path/myproject/
/some/path/myproject/some_script
/some/path/myproject/some_other_script
/some/path/myproject/set_paths.py
/some/path/myproject/setttings.py
/some/path/myproject/lib/ # some external libraries/apps checked in with my project.
/some/path/myproject/myapp/ # my apps etc.
This way myproject folder can be moved anywhere on the file system, and calling right path, settings.py is used.
Call this function as the first thing in your cron, or console script; it will bootstrap Django, and allow you to access all of the Django modules from the console, with out using 'python manage.py shell'
Examples:
# A script within your django project.
from django_bootstrap import bootstrap
bootstrap(__file__)
--- or ---
# A cron script located outside of your django project
from django_bootstrap import bootstrap
bootstrap("/path/to/your/project/root/")
- django
- console
- cron
- bootstrap
2 snippets posted so far.