Created
January 11, 2015 21:43
-
-
Save edgabaldi/1b3b4d707a36b4186e86 to your computer and use it in GitHub Desktop.
setup django environment outside django
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
import os | |
import django | |
from myapp import models | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") | |
django.setup() | |
print models.MyModel.objects.get(pk=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment