Home > Mobile >  how to get a particular field from django model
how to get a particular field from django model

Time:07-15

I want a command for getting a query set from the model. The SQL command will be like

SELECT teamName FROM TABLE WHERE userName=userName;

CodePudding user response:

you can retrive list of field from model by using values_list

Model.Objects.filter(userName = userName).values_list('teamName')

CodePudding user response:

I found the answer

teamNameQuery=userInfo.objects.filter(userName=userName).values('teamName').first()
  • Related