【问题标题】:How to map model data(query set) into dictionary and use it as ordered list如何将模型数据(查询集)映射到字典中并将其用作有序列表
【发布时间】:2020-09-10 14:26:10
【问题描述】:

【问题讨论】:

    标签: python django dictionary django-models django-queryset


    【解决方案1】:

    也许如果你发布一个示例或代码,它会更清楚,但我认为你需要这样的东西: 例如,如果您的模型名为 Data

    values=Data.objects.value().order_by('field_name') # make a query and order data
    list=[value for value in values ]   # storage data as a list of dictionaries
    
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-30
      • 2021-07-14
      • 1970-01-01
      • 2010-12-31
      相关资源
      最近更新 更多