按建立時間倒序查詢測試用例python
>>> a= TestCase.query.order_by(TestCase.create_time.desc()).first() >>> a <TestCase.首頁查看所有xxx>
注意 order_by()括號中的寫法:測試
直接寫creater_time.desc()會報AttributeErrorui
>>> a= TestCase.query.order_by(id.desc()).first() Traceback (most recent call last): File "/usr/lib/python3.6/code.py", line 91, in runcode exec(code, self.locals) File "<console>", line 1, in <module> AttributeError: 'builtin_function_or_method' object has no attribute 'desc'
正確的寫法是TestCase.creater_time.desc()spa