I am trying to get the models from django but nothing is showing up. The app is deployed on Google App Engine.
This is the errors I see:
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'
Below are my urls, view functions:
URL:
('^get_companies_json$', 'companies.views.all_companies_json')
views function:
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);
});
}
);
I am following the example on jQuery site: http://api.jquery.com/jQuery.getJSON/
What am I doing wrong?
I think that this function
Needs to be changed to