为什么Angular会导致GAE失败?

时间:2014-03-18 20:25:23

标签: python django angularjs google-app-engine django-templates

我一直在使用Google应用引擎托管我的网页,我在那里排练我的编码技巧。我的网站建立在Foundation框架之上。我开始玩Angular并且appengine返回一条错误消息:


Traceback (most recent call last): 
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 714, in __call__handler.get(*groups)
File "/base/data/home/apps/s~verkkolakimies/1.374513895376995789/main.py", line 16, in get self.response.out.write (template.render (path, {}))
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 91, in render
t = _load_user_django(template_path, debug)
File "/base/data/home/runtimes/python/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 113, in _load_user_django
template = django.template.loader.get_template(file_name)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 80, in get_template
template = get_template_from_string(source, origin, template_name)
 File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/loader.py", line 88, in get_template_from_string
return Template(source, origin, name)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 158, in __init__
self.nodelist = compile_string(template_string, origin)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 174, in compile_string
return parser.parse()
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 254, in parse
filter_expression = self.compile_filter(token.contents)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 338, in compile_filter
return FilterExpression(token, self)
File "/base/data/home/runtimes/python/python_lib/versions/third_party/django-0.96/django/template/__init__.py", line 558, in __init__
raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
TemplateSyntaxError: Could not parse the remainder:  + " "+ sukunimi

我追踪的问题是添加角度代码:

 <div class="panel radius">
 Vainajan nimi: {{etunimi + " "+ sukunimi}}<br>
 Tyttönimi: {{tyttonimi}}<br>
 Henkilötunnus: {{vainaja_hetu}}<br>
 Ammatti: {{ammatti}}<br>
 Syntynyt: {{vainaja_hetu}}<br> Kuollut: {{deathDate}} <br>
 Postinumero: {{zip}}
 </div>

我从同一页面形式获取角度数据:

    

  <form action="#" method="POST" name="perukirjakone" ng-init="sukunimi=juttu; etunimi=tuttu">
    <fieldset id="perittäväSet" class="color3">
      <legend class="fi-info"> XXX</legend>

      <label for="vainaja_first_name" >Vainajan etunimi</label><br>
      <input  type="text" required name="vainaja_first_name" id="vainaja_first_name" tabindex="1" placeholder="Esa" ng-model="etunimi"> 

两个花括号是否会抛弃Python,还是应该在代码中查找其他泄漏?我想我的问题是Angular和GAE存在已知问题吗?

2 个答案:

答案 0 :(得分:4)

这与App Engine无关,它与您使用的框架Django有关。

Django在他们的模板中也使用双花括号,这与AngularJS冲突。

请参阅:AngularJS with Django - Conflicting template tags

答案 1 :(得分:1)

罗宾有它。 Django模板和Angular都想使用{{。有建议解决这个问题,并在http://django-angular.readthedocs.org/en/latest/integration.html

中解决其他一些Django / Angular问题

我只使用了Angular和GAE几次,并发现将Angular部分隔离到静态文件中,并使用GAE来提供Ajax请求,效果非常好。