使用jQuery读取Django';s系列化

使用jQuery读取Django';s系列化,jquery,django,Jquery,Django,我正在使用Django序列化成功地生成JSON对象。我是这样认为的: def fetch_content(request, content_id): content = serializers.serialize('json', [ContentQueue.objects.get(id=content_id)], fields=('title', 'description')) mimetype = 'application/javascript; charset=utf8' return

我正在使用Django序列化成功地生成JSON对象。我是这样认为的:

def fetch_content(request, content_id):

content = serializers.serialize('json', [ContentQueue.objects.get(id=content_id)], fields=('title', 'description'))
mimetype = 'application/javascript; charset=utf8'

return HttpResponse(content, mimetype)
这会像这样输出JSON:

[{"pk": 24, "model": "contentqueue", "fields": {"description": "Aerosmith frontman Steven Tyler was typically gabby...", "title": "Steven Tyler Tells All: On The Cover of Rolling Stone"}}]
我尝试使用以下jQuery代码读取此JSON文件:

api_url = /fetch-content/ + content_id;
$.getJSON(api_url, function(json) {
    var type = json.title;
    var desc = json.description;
    <then I display the content onscreen>
api\u url=/fetch content/+content\u id;
$.getJSON(api_url,函数(json){
var type=json.title;
var desc=json.description;
我尝试过通过json.fields.title访问内容,但没有成功。我做错了什么

var type = json[0].fields.title
您首先必须定义数组索引。除此之外,您的思路是正确的