I'm building an album app in django, I have two django model
class Album(models.Model):
name = models.CharField(max_length=100)
family = models.ForeignKey(FamilyProfile)
created_by = models.ForeignKey(User)
created_date = models.DateField(default=datetime.datetime.now())
class Image(models.Model):
album = models.ForeignKey(Album)
name = models.CharField(max_length=100,null=True,blank=True)
src = models.ImageField(upload_to=MEDIA_ROOT)
upload_by = models.ForeignKey(User)
upload_time = models.DateTimeField(default=datetime.datetime.now())
and using tastypir for RESFull api,
in backbone I have two collections
album.albumCollection = Backbone.Tastypie.Collection.extend({
url:'/album/v1/album/',
model:album.albumModel,
})
image.imageCollection = Backbone.Tastypie.Collection.extend({
url:'/album/v1/image/',
model:image.imageModel,
})
and backbone router
album.router = Backbone.Router.extend({
routes:{
'':'album',
'test/:id':'openAlbum',
},
album:function(){
this.albums = new album.albumCollection()
this.albumsView = new album.albumCollectionView({model:this.albums})
this.albums.fetch({reset: true})
},
openAlbum:function(id){
this.images = new image.imageCollection()
this.imagesView = new image.imageCollectionView({model:this.albums})
this.images.fetch({reset: true})
}
})
new album.router();
Backbone.history.start();
I can get the album rendered, but when I try to open the album, as you can see I need to fetch the image collection by the album's id, but the imageCollection.url is static.
how can I get the images inside a album with backbone and tastypie?