码迷,mamicode.com
首页 > 数据库 > 详细

django.db.models.query.QuerySet格式的数据输出

时间:2021-05-03 11:51:42      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:console   cts   host   model   turn   core   import   运行   UNC   

1、

def findmtm2(request):
import serializer
import json
# 多对多跨表正向查询
# res = softlist.objects.filter(hostlists__ip="10.116.6.177").values("softname")
res2=softlist.objects.filter(hostlists__ip="10.116.9.233").values_list("softname")
print("res2的数据输出是:",res2)

print("res2的类型是:",type(res2))

for nn in res2:
  print(nn,type(nn))


for m in res2:
# print(m,type(m))
  for mmm in m:
  print(mmm)

return HttpResponse("ok,mtm2 search success!!!")

____________________________

程序运行结果:

res2的数据输出是: <QuerySet [(‘Acronis Backup‘,), (‘Analytics Instance001‘,), (‘CommCellConsole Instance001‘,), (‘CommServe Instance001‘,), (‘DiagnosticsAndUsageServer Instance001‘,), (‘Java 8 Update 201 (64-bit)‘,), (‘Java SE Development Kit 8 Update 201 (64-bit)‘,), (‘MediaAgent Instance001‘,), (‘MediaAgentCore Instance001‘,), (‘MessageQueue Instance001‘,), (‘Microsoft .NET Core Host - 2.1.16 (x64)‘,), (‘Microsoft .NET Core Host - 2.1.5 (x64)‘,), (‘Microsoft .NET Core Host FX Resolver - 2.1.16 (x64)‘,), (‘Microsoft .NET Core Host FX Resolver - 2.1.5 (x64)‘,), (‘Microsoft .NET Core Runtime - 2.1.16 (x64)‘,), (‘Microsoft .NET Core Runtime - 2.1.5 (x64)‘,), (‘Microsoft ASP.NET Core 2.1.16 Shared Framework (x64)‘,), (‘Microsoft ASP.NET Core 2.1.5 Shared Framework (x64)‘,), (‘Microsoft ASP.NET Core Module‘,), (‘Microsoft Help Viewer 1.1‘,), ‘...(remaining elements truncated)...‘]>
res2的类型是: <class ‘django.db.models.query.QuerySet‘>
Acronis Backup
Analytics Instance001
CommCellConsole Instance001
CommServe Instance001
DiagnosticsAndUsageServer Instance001
Java 8 Update 201 (64-bit)
Java SE Development Kit 8 Update 201 (64-bit)

 

django.db.models.query.QuerySet格式的数据输出

标签:console   cts   host   model   turn   core   import   运行   UNC   

原文地址:https://www.cnblogs.com/yaok430/p/14721925.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!