#!/usr/bin/env python3 import os import sys root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) os.chdir(root_dir) # using virtualenv's activate_this.py to reorder sys.path activate_this = os.path.join(root_dir, '..', 'bin', 'activate_this.py') with open(activate_this) as f: code = compile(f.read(), activate_this, 'exec') exec(code, dict(__file__=activate_this)) # execfile(activate_this, dict(__file__=activate_this)) if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)