Returning JSON array from a Django view to a template

后端 未结 3 893
野趣味
野趣味 2020-11-30 09:42

I\'m using Django to create a web-based app for a project, and I\'m running into issues returning an array from a Django view to a template.

The array will be used b

3条回答
  •  暖寄归人
    2020-11-30 10:30

    You can also use simplejson from django.utils. Like:

    oldAnnotations = lastFrame.videoannotation_set.filter(ParentVideoLabel=label)
    dump = simplejson.dumps(oldAnnotations)
    
    return HttpResponse(dump, mimetype='application/json')
    

    You can parse and reach all data in this from JS side.

提交回复
热议问题