-
-
Save rcrowley/79156 to your computer and use it in GitHub Desktop.
Django Shell Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Django Shell Script | |
Richard Crowley <[email protected]> | |
I like organized directory structures. Because of the way the Python | |
path works, there wasn't a readily-available way to stash shell scripts | |
that needed access to Django goodness away in bin/. This is a bit | |
heavy on the scaffolding code (six lines, geez) but works. | |
""" | |
import os | |
import sys | |
sys.path[0] = os.path.normpath(os.path.join(sys.path[0], '..')) | |
from django.core.management import setup_environ | |
import settings | |
setup_environ(settings) | |
# Now you can import from your Django app! | |
# The proof is in the print() | |
if '__main__' == __name__: | |
print(dir(settings)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment