【发布时间】:2013-02-25 22:19:01
【问题描述】:
我正在使用带有 python 2.7 的 Google App Engine 并尝试重现 https://github.com/GoogleCloudPlatform/appengine-paging-python/blob/master/suggest_cursor.py 给出的示例以在我的页面内使用光标分页(请参阅 https://developers.google.com/appengine/articles/paging)
数据模型.py
class Feedback(db.Model):
user = db.ReferenceProperty(User)
subject = db.StringProperty()
text = db.TextProperty(default='')
created = db.DateTimeProperty(auto_now_add=True)
我的代码看起来很相似,但出现错误:
1)
query = datamodel.Feedback.all().order(-datamodel.Feedback.created)
TypeError: bad operand type for unary -: 'DateTimeProperty'
2) 删除 - query = datamodel.Feedback.all().order(datamodel.Feedback.created) 结果就是这个错误
File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/db/__init__.py", line 2614, in order
if property.startswith('-'):
AttributeError: 'DateTimeProperty' object has no attribute 'startswith'
知道为什么这不能按预期工作吗?
【问题讨论】:
标签: python google-app-engine pagination cursor data-modeling