问题:
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined
解决办法:
import os
import django
django.setup()
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')