DJANGO_SETTINGS_MODULE is undefined

 
>>> from django.template import Template, Context
>>> t = Template('My name is {{ my_name }}.')
throw out DJANGO_SETTINGS_MODULE is undefined
Here is the solution: 
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。

0 comments

Popular Posts

无觅相关文章插件,迅速提升网站流量