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')
精彩评论