简体   繁体   English

与Django和Google App Engine混淆

[英]Confused with Django and Google App Engine

I think I'm using Django in google app engine this way: 我想我是这样在Google App Engine中使用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 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. 我不明白我正在做的事情和使用google文档中上述方式使用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 谢谢

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. Google App Engine过去随附了较早版本的Django,并且为了使用最新版本,您必须执行此操作。 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). 我不确定现在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 %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM