开发者

print value of a column in django

开发者 https://www.devze.com 2022-12-21 12:48 出处:网络
How to print the test field in the following query in django res=Resources.objects.filter(test=reques开发者_C百科t.profile)

How to print the test field in the following query in django

res=Resources.objects.filter(test=reques开发者_C百科t.profile)
logging.debug(test) # won't work

I wanted to check what this value is compared with..


You have to iterate through res and print each model's value of test in turn.


You may also try the values_list method, eg:

Resource.objects.filter(test=request.profile).values_list("test")

It returns a list of tuples with the value of "test" for each matched record.

0

精彩评论

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