无法想象为什么我无法获得相关项目和模型项目。
我有一个模型
App.Staple = DS.Model.extend({
description: DS.attr('string'),
name: DS.attr('string'),
album: DS.belongsTo('App.Album')
});
App.Album = DS.Model.extend({
description: DS.attr('string'),
name: DS.attr('string'),
staples: DS.hasMany('App.Staple')
});
连接到 django-tastypie。数据样本:
获取 /api/v1/staple/1/
{"album_id": "/api/v1/album/1/", "created": "2012-12-27T11:14:38.320364", "description": "asdlfkjasldkfj", "id": 1, "lead_count": 0, "rank": 0, "resource_uri": "/api/v1/staple/1/", "slug": "slug", "status": "public"}
获取 /api/v1/专辑/1/
{"album_staples": ["/api/v1/staple/1/"], "created": "2012-12-27T11:14:23.433934", "description": "", "followed_count": 0, "id": 1, "name": "Album Staple", "rank": 0, "resource_uri": "/api/v1/album/1/", "slug": "staple_album", "status": "public"}
问题是
console.log(App.Staple.find(1).get('album'))
给出空值。
霍维尔
App.Album.find(1).get('staples')
退货还可以。
完整的 js 代码在这里:http: //jsfiddle.net/zczyX/