Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Created January 11, 2015 21:43
Show Gist options
  • Save edgabaldi/1b3b4d707a36b4186e86 to your computer and use it in GitHub Desktop.
Save edgabaldi/1b3b4d707a36b4186e86 to your computer and use it in GitHub Desktop.
setup django environment outside django
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