I am using ember django adapter as my backend is designed in python/django.(http://ift.tt/1CBLwrf)
feed.js (model)
import DS from 'ember-data';
const {attr} = DS
export default DS.Model.extend({
gallery_name:attr('string'),
thumbnail_url:attr('string'),
is_following:attr('boolean'),
time:attr('string'),
description:attr('string'),
feedPhotos:DS.hasMany('feedPhoto',{embedded:'always'})
});
feedphoto.js(model)
import DS from 'ember-data';
export default DS.Model.extend({
feed: DS.belongsTo('feed'),
url: DS.attr(),
profilePic: DS.attr(),
userName: DS.attr(),
userKarma: DS.attr(),
caption: DS.attr(),
numComments: DS.attr(),
owner: DS.attr(),
time: DS.attr(),
photo_url: DS.attr(),
comments_url: DS.attr(),
numFives: DS.attr(),
fivers_url: DS.attr(),
fivers_pk: DS.attr(),
fullphoto_url: DS.attr(),
fullphoto_pk: DS.attr(),
is_fived: DS.attr('boolean'),
hiFiveKarma: DS.attr(),
owner_pk: DS.attr(),
userFirstName: DS.attr(),
is_bookmarked: DS.attr('boolean')
});
feed.js(serializer)
import DRFSerializer from './drf';
import DS from 'ember-data';
export default DRFSerializer.extend(DS.EmbeddedRecordsMixin,{
primaryKey: 'pk',
attrs:{
feedPhotos:{ embedded: 'always' }
}
});
feedphoto.js(serailizer)
import DRFSerializer from './drf';
import DS from 'ember-data';
export default DRFSerializer.extend({
primaryKey: 'pk',
});
response.json
[{
"pk": 127,
"url": "http://ift.tt/1Y7qNWd",
"gallery_name": "Faces",
"thumbnail_url": "http://ift.tt/1SYQwiz",
"time": "1 month ago",
"description": "Created by user",
"is_following": true,
"feedPhotos": [{
"pk": 574,
"url": "http://ift.tt/1NQQt8b",
"profilePic": "http://ift.tt/1SYQyqD",
"userName": "Rohini",
"userKarma": 194,
"caption": "Life @ Myanmar!",
"numComments": 0,
"owner": "http://ift.tt/1NQQt8d",
"time": "2 months ago",
"photo_url": "http://ift.tt/1mehxUv",
"comments_url": "http://ift.tt/1SYQyqF",
"numFives": 2,
"fivers_url": "http://ift.tt/1NQQuZV",
"fivers_pk": 1303,
"fullphoto_url": "http://ift.tt/1SYQwyP",
"fullphoto_pk": 1303,
"is_fived": false,
"hiFiveKarma": 0,
"owner_pk": 45,
"userFirstName": "Rohini",
"is_bookmarked": false
}, {
"pk": 446,
"url": "http://ift.tt/1NQQt8j",
"profilePic": "http://ift.tt/1SYQyGV",
"userName": "Shushma",
"userKarma": 224,
"caption": "",
"numComments": 0,
"owner": "http://ift.tt/1NQQuZZ",
"time": "2 months ago",
"photo_url": "http://ift.tt/1SYQyGX",
"comments_url": "http://ift.tt/1NQQt8l",
"numFives": 3,
"fivers_url": "http://ift.tt/1NQQv03",
"fivers_pk": 1315,
"fullphoto_url": "http://ift.tt/1SYQyH1",
"fullphoto_pk": 1315,
"is_fived": false,
"hiFiveKarma": 0,
"owner_pk": 34,
"userFirstName": "Shushma",
"is_bookmarked": false
}]
}]
The code is able to save the feed model details but not the feedphoto model.In my ember inspector the feed model show the correct data.But the feedphoto model is not showing any data.My not sure why I am going wrong.
Aucun commentaire:
Enregistrer un commentaire