开发者

django order's problem

blow is my database:

class TestCases(TmstafServerModel):
    name = models.CharField(max_length=30)

class TestRunSummary(TmstafServerModel):
    testResult = models.ForeignKey(TestResult)
    testCases = models.ForeignKey(TestCases)
    platform = models.ForeignKey(Platform)

I want to get data order by testcase's name, such as:

all_fail_case = TestRunSummary.objects.all().order_by('testCases.name')

but it not work, how can i get all records in TestRunSummary which ordering by testCases name? thanks:开发者_如何学C)


Use __ instead of . like described in the documentation. Alternatively you can also specify a default ordering for the TestCase model and sort by testCases.

all_fail_case = TestRunSummary.objects.order_by('testCases__name').all()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜