Skip to content

Instantly share code, notes, and snippets.

@Lh4cKg
Last active May 22, 2018 21:25
Show Gist options
  • Save Lh4cKg/3993a05473dc43909770c46e18172e98 to your computer and use it in GitHub Desktop.
Save Lh4cKg/3993a05473dc43909770c46e18172e98 to your computer and use it in GitHub Desktop.
configure and run django script file
# old django version: 1.6.x
# configure and run django script
if __name__ == '__main__':
import os
import sys
import importlib
proj_path = '/home/gogua/projects/profenv/profiling/'
sys.path.append(proj_path)
os.chdir(proj_path)
os.environ["DJANGO_SETTINGS_MODULE"] = "profiling.settings.lg"
importlib.import_module("profiling.settings.lg")
from django.conf import settings
reload(sys)
sys.setdefaultencoding("utf-8") # @UndefinedVariable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment