Skip to content

Instantly share code, notes, and snippets.

@jgillmanjr
Created April 5, 2017 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgillmanjr/0341932f91172e01ad34196bdb8c02c6 to your computer and use it in GitHub Desktop.
Save jgillmanjr/0341932f91172e01ad34196bdb8c02c6 to your computer and use it in GitHub Desktop.
Get into a django app from an external script - Django 1.10
import sys
import os
project_name = 'your_project'
project_path = '/your/path/here' # Or however you want to build it
project_settings_module = project_name + '.settings'
sys.path.append(project_path)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', project_settings_module)
import django
from django.conf import settings
from django.apps import apps
django.setup()
yourapp = apps.get_app_config('your_app')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment