我正在使用带有 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'
知道为什么这不能按预期工作吗?