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('/')
数据正在输入但未输出。-
编辑: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)
和这样的模板:
var storedCourses = "{{ timetable.courses }}";