开发者

SELECT Column1 FROM tablename in Django

Okay I know this is really stup开发者_Python百科id.But how to i write SELECT Column1 FROM tablename I know i can use Court.objects.all()[0] to get just one row.But how do I get one column only(the whole column values).Am I missing something?

Also in Court.objects.all()[0] isn't it first retrieved and then spliced.So isn't it kinda inefficient.


Court.objects.values_list('column_name', flat=True)

And if you write Court.objects.all()[0] only one row is retireved.


Court.objects.only('column_name')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜