I think I'm using Django in google app engine this way:
我想我在谷歌应用引擎中使用Django这样:
from google.appengine.ext.webapp import template
...
self.response.out.write(template.render('view/some_name.html', viewVals))
But I read somewhere that to use Django, you need to do this:
但我读到了使用Django的地方,你需要这样做:
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library
use_library('django', '1.2')
https://developers.google.com/appengine/docs/python/tools/libraries#Django
I don't understand what is the difference between what I'm doing and using Django the way described above in the google documentation.
我不明白我正在做什么和使用Django之间的区别在于谷歌文档中描述的方式。
Also, if I do attempt to use it in this way, how do I know I succeeded? Do I still use:
另外,如果我尝试以这种方式使用它,我怎么知道我成功了?我还在使用:
self.response.out.write(template.render('view/some_name.html', viewVals))
Please help clarify this. Thanks
请帮助澄清一下。谢谢
1 个解决方案
#1
1
Google App Engine used to ship with an older version of Django and in order to use the newest you had to do that trick. I'm not sure what's the default version on Django now (I personally using Jinja2, and you can go through the Getting Started to see how to use it with GAE).
Google App Engine过去常常附带较旧版本的Django,并且为了使用最新版本,您必须使用该技巧。我不确定Django上的默认版本是什么(我个人使用Jinja2,你可以通过入门看看如何在GAE中使用它)。
In order to test if you're succeeded or not, use the in operator, that was introduced in Django 1.2, if it worked then you don't need the extra setting, otherwise use it.
为了测试你是否成功,使用Django 1.2中引入的in运算符,如果它工作,那么你不需要额外的设置,否则使用它。
{% if "bc" in "abcdef" %}
This appears since "bc" is a substring of "abcdef"
{% endif %}
#1
1
Google App Engine used to ship with an older version of Django and in order to use the newest you had to do that trick. I'm not sure what's the default version on Django now (I personally using Jinja2, and you can go through the Getting Started to see how to use it with GAE).
Google App Engine过去常常附带较旧版本的Django,并且为了使用最新版本,您必须使用该技巧。我不确定Django上的默认版本是什么(我个人使用Jinja2,你可以通过入门看看如何在GAE中使用它)。
In order to test if you're succeeded or not, use the in operator, that was introduced in Django 1.2, if it worked then you don't need the extra setting, otherwise use it.
为了测试你是否成功,使用Django 1.2中引入的in运算符,如果它工作,那么你不需要额外的设置,否则使用它。
{% if "bc" in "abcdef" %}
This appears since "bc" is a substring of "abcdef"
{% endif %}