为什么Angular会导致GAE失败?

时间:2023-01-14 09:08:13

I have been using Google app engine to host my web pages where I rehearse my coding skills. My site is built on top of Foundation framework. I started playing around with Angular and the appengine returns an error message:

我一直在使用谷歌应用引擎来托管我的网页,在那里我排练我的编码技巧。我的网站建立在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

I traced the issue to adding angular code:

我追溯了添加角度代码的问题:

 <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>

I am getting the angular data from the same page form:

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

  <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"> 

Are the two curly braces throwing the Python off or should I look for other leaks in my code? I guess my question is that that are there known problems with Angular and GAE?

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

2 个解决方案

#1


4  

This is not related to App Engine, it is related to Django which is the framework you use.

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

Django also use double curly brackets in their templates which makes it conflict with AngularJS.

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

See: AngularJS with Django - Conflicting template tags

请参阅:带有Django的AngularJS - 冲突的模板标记

#2


1  

Robin has it. Both Django templates and Angular want to use {{. There's advice for working around that, and for working around some other Django/Angular issues, in http://django-angular.readthedocs.org/en/latest/integration.html

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

I've only used Angular with GAE a few times, and found that isolating the Angular parts into static files, and using GAE to serve up Ajax requests, worked quite well.

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

#1


4  

This is not related to App Engine, it is related to Django which is the framework you use.

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

Django also use double curly brackets in their templates which makes it conflict with AngularJS.

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

See: AngularJS with Django - Conflicting template tags

请参阅:带有Django的AngularJS - 冲突的模板标记

#2


1  

Robin has it. Both Django templates and Angular want to use {{. There's advice for working around that, and for working around some other Django/Angular issues, in http://django-angular.readthedocs.org/en/latest/integration.html

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

I've only used Angular with GAE a few times, and found that isolating the Angular parts into static files, and using GAE to serve up Ajax requests, worked quite well.

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