django 返回json数据

1 from django.core                        import serializers
2 
3 @login_required
4 def ajax_get_data(request):
5     json_data = serializers.serialize("json", MyModel.objects.all())
6     return HttpResponse(json_data,content_type="application/json")

 

posted @ 2014-12-22 14:35  r3call  阅读(9956)  评论(0编辑  收藏  举报