最近为了在应用中也共用modle,找到django下能使用的办法,把环境变量设为DJANGO_SETTINGS_MODULE=settings就好了

import os,sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.conf import settings

settings.configure(DATABASE_ENGINE = 'mysql',

DATABASE_NAME = 'I',

DATABASE_USER = '',

DATABASE_PASSWORD = '',

DATABASE_HOST = '',

DATABASE_PORT = '3306')

from*.models import*