Created
May 7, 2018 13:40
-
-
Save develmaycare/1d03f21f35e40418ec47f7814103e30a to your computer and use it in GitHub Desktop.
Standalone Django scripting.
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 | |
import os | |
import sys | |
# Define the path to the project. | |
PROJECT_PATH = os.path.abspath(os.path.join("example", "source")) | |
# Let Django know where things are. | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") | |
sys.path.append(PROJECT_PATH) | |
# Change directory for relative paths to work. | |
os.chdir(PROJECT_PATH) | |
# Initialize Django. | |
from django.core.wsgi import get_wsgi_application | |
application = get_wsgi_application() | |
# Start scripting. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment