DJANGO_SETTINGS_MODULE is undefined
时间:2010-04-17 来源:angelia_liu
>>> from django.template import Template, Context
>>> t = Template('My name is {{ my_name }}.')
抛出了DJANGO_SETTINGS_MODULE is undefined, 网上查了下, 找到2种方法
1.
>>> from django.template import Template, Context
>>> from django.conf import settings
>>> settings.configure()
>>> t = Template('My name is {{ my_name }}.')
>>> c = Context({'my_name': 'Daryl Spitzer'})
>>> t.render(c)
参考:书http://stackoverflow.com/questions/98135/how-do-i-use-django-templates-without-the-rest-of-django
2.
在系统环境变量中添加DJANGO_SETTINGS_MODULE变量,将其值设置为mysite.settings 添加PYTHONPATH:D:\\Program Files\\python25\\DLLs;F:\workforce\python (F:\workforce\python为python project的工作目录,存放project, mysite是一个project目录,seetings为她的设置模块) 重新启动一个cmd,进入python。 相关阅读 更多 +