如何在Django/Python中使用Gijgo网格?

2024-09-30 08:33:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用下面的代码在Gijgo网格中显示我的数据库记录。不幸的是,它不起作用,因为Gijgo默认情况下需要没有键的JSON数据。在

据我所知,解决这个问题有两种选择:

  • 去掉JSON中的键(modelpkfields),这是Gijgo所接受的
  • 配置Gijgo以理解我的JSON结构(找不到任何有关此方法的信息)

你知道我怎么解决这个问题吗?在

编码

demand = Demand.objects.filter(week__number=request.GET["weeknumber"], week__year=request.GET["weekyear"])
response = serializers.serialize("json", demand)
return HttpResponse(response, content_type='application/json')

[{"model": "demand", "pk": 4, "fields": {"week": 3, "model": 1, "product": 3, "type": 7, "build": 1, "sdna": 1234, "rcna": 234234, "sdeu": 3333, "rceu": 433, "ssd": 53, "src": 63, "notes": "fafd"}}]

Tags: 代码数据库json网格fieldsgetmodelresponse

热门问题