Skip to content

Instantly share code, notes, and snippets.

@mbylstra
Last active March 5, 2019 23:14
Show Gist options
  • Save mbylstra/5893273 to your computer and use it in GitHub Desktop.
Save mbylstra/5893273 to your computer and use it in GitHub Desktop.
Django scratchpad file. A standalone Django script with the django environment loaded.Place in the root of your Django project. Assumes your settings.py is in a folder named 'main'.
import os
import sys
project_dir = os.path.realpath(__file__)
sys.path.append(project_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = 'main.settings'
import django
from django.conf import settings
django.setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment