import sys, os sys.path.append('/path/to/your/project') # The directory that contains settings.py # Set up the Django settings/environment from django.core.management import setup_environ from myproject import settings setup_environ(settings)