Skip to content

Instantly share code, notes, and snippets.

@amatellanes
Last active March 9, 2018 22:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amatellanes/11119500 to your computer and use it in GitHub Desktop.
Save amatellanes/11119500 to your computer and use it in GitHub Desktop.
Bypassing manage.py in Django.
from django.core.management import setup_environ
from myproject import settings
setup_environ(settings)
# As of Django 1.4
import os
from django.conf import settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
# As of Django 1.7
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
django.setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment