我正在尝试从 django 获取模型,但没有显示任何内容。该应用程序部署在 Google App Engine 上。
这是我看到的错误:
AttributeError at /get_companies_json
'str' object has no attribute 'status_code'
Request Method: GET
Request URL: http://127.0.0.1:8000/get_companies_json
Django Version: 1.3
Exception Type: AttributeError
Exception Value:
'str' object has no attribute 'status_code'
以下是我的网址,查看功能:
网址:
('^get_companies_json$', 'companies.views.all_companies_json')
视图功能:
def all_companies_json(request):
# json_serializer = serializers.get_serializer("json")();
companies_json = serializers.serialize("json", Company.objects.filter(approved = True));
return companies_json;
jQuery:
$.getJSON("/get_companies_json",
function(data){
$.each(data.items, function(i, item){
console.log(item);
});
}
);
我正在关注 jQuery 网站上的示例:http: //api.jquery.com/jQuery.getJSON/
我究竟做错了什么?