Skip to content

Instantly share code, notes, and snippets.

@gaganpreet
Created July 11, 2013 17:38
Show Gist options
  • Save gaganpreet/5977531 to your computer and use it in GitHub Desktop.
Save gaganpreet/5977531 to your computer and use it in GitHub Desktop.
Use Django ORM in other Python projects
import os
import sys
cwd = os.path.dirname(__file__)
sys.path.insert(0, os.path.realpath(os.path.join(cwd, '/path/to/django/root/')))
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
from myapp.models import ModelA, ModelB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment