How to serialize Django queryset.values() into json?

前端 未结 5 388
情话喂你
情话喂你 2020-12-13 13:31

I have a model that has many fields, however for this problem I only need 3 of those fields. When I try to serialize a .values set I get an exception:

5条回答
  •  無奈伤痛
    2020-12-13 14:07

    Make list from objectQuerySet:

    data_ready_for_json = list( ConventionCard.objects.filter(ownerUser = user).values('fileName','id') )
    

提交回复
热议问题