0
我使用谷歌應用程序引擎使用Python 2.7,並嘗試重現在https://github.com/GoogleCloudPlatform/appengine-paging-python/blob/master/suggest_cursor.py給使用分頁與光標我的網頁裏面的例子(見https://developers.google.com/appengine/articles/paging)類型錯誤:壞數類型爲一元 - :「DateTimeProperty的」
數據模型的.py
class Feedback(db.Model):
user = db.ReferenceProperty(User)
subject = db.StringProperty()
text = db.TextProperty(default='')
created = db.DateTimeProperty(auto_now_add=True)
我的代碼看起來安靜similiar但我得到的錯誤:
1)
query = datamodel.Feedback.all().order(-datamodel.Feedback.created)
TypeError: bad operand type for unary -: 'DateTimeProperty'
2)去除 - 查詢= datamodel.Feedback.all()命令(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'
任何想法,爲什麼預期這將無法正常工作?
謝謝啊,因爲沒有數據模型我沒有認識到的例子是基於NDB。甚至不知道ndb!謝謝 – skurt 2013-02-25 17:23:17