Google App engine seems very confusing. I am trying to fetch data stored in the server. But nothing is fetched. Down, you will find the code. I donot get what is wrong. Code:
Google App引擎似乎非常令人困惑。我正在尝试获取存储在服务器中的数据。但没有任何东西。向下,你会找到代码。我不知道什么是错的。码:
def get(self):
user = users.get_current_user()
if user:
timetable_query = Timetable.query(ancestor = tt_key(user.email()))
timetable = timetable_query.fetch(10)
template_values = {
'timetable': timetable
}
template = JINJA_ENVIRONMENT.get_template('main.html')
self.response.write(template.render(template_values))
else:
self.redirect(users.create_login_url(self.request.uri))
def post(self):
user = users.get_current_user()
if user:
timetable = Timetable(parent = tt_key(user.email()))
timetable.owner = user;
timetable.courses = self.request.get('courses')
timetable.put()
self.redirect('/')
The data is going in but not coming out. -
数据进入但没有出来。 -
Edit: The ndb model class is like so:
编辑:ndb模型类是这样的:
class Timetable(ndb.Model):
owner = ndb.UserProperty()
courses = ndb.StringProperty(indexed=False)
shared = ndb.StringProperty(indexed=False)
date = ndb.DateTimeProperty(auto_now_add=True)
and the template like so:
和模板如下:
var storedCourses = "{{ timetable.courses }}";
1 个解决方案
#1
0
I recommend that you can use logging to inspect your variables. Just import logging
and debug:
我建议您可以使用日志记录来检查变量。只需导入日志记录和调试:
https://developers.google.com/appengine/articles/logging
In this case the problem was in the template which you would have noticed if you had logged the values on your request handler.
在这种情况下,问题出现在模板中,如果您已在请求处理程序上记录了值,则会注意到该模板。
#1
0
I recommend that you can use logging to inspect your variables. Just import logging
and debug:
我建议您可以使用日志记录来检查变量。只需导入日志记录和调试:
https://developers.google.com/appengine/articles/logging
In this case the problem was in the template which you would have noticed if you had logged the values on your request handler.
在这种情况下,问题出现在模板中,如果您已在请求处理程序上记录了值,则会注意到该模板。