我想知道这个片段到底是做什么的? (见http://code.google.com/p/google-app-engine-samples/source/browse/trunk/django_example/django_bootstrap.py)
# Make sure we can import Django. We may end up needing to do this
# little dance, courtesy of Google third-party versioning hacks. Note
# that this patches up sys.modules, so all other code can just use
# "from django import forms" etc.
try:
from django import v0_96 as django
except ImportError:
pass
答案 0 :(得分:3)
正如我之前在another question中所述,你可以在app引擎中使用不同的django版本(目前从0.96到1.2)。默认情况下,它仍然使用0.96作为django(这是此代码片段的作用)。虽然您可以通过向main.py
添加以下内容来更改此内容:
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library
use_library('django', '1.2')