これが私のdjango view
@csrf_exempt
@login_required
def get_playlists_for_user(request):
"""
gets all playlists for user
"""
logging.info('getting playlist for user - ' + str(request.user))
playlists = UserPlaylist.objects.get_all_playlists_for_user(request.user)
logging.info('user=%s, playlists=%s'%(request.user, playlists))
return HttpResponse(playlists)
これがどのjQuery
ようにそれを呼び出すかですajax
$.ajax({
url: '/getUserPlaylists',
success: function(response, textStatus, jqXHR){
console.log(response);
},
error: function(response, textStatus, jqXHR) {
}
});
ビューは Playlist オブジェクトのリストを返します
playlists=[<Playlist id:1, name:first, date_created:2012-08-05 06:28:31.954623+00:00, deleted:False>, <Playlist id:2, name:my, date_created:2012-08-06 12:47:13.023537+00:00, deleted:False>, <Playlist id:3, name:new, date_created:2012-08-06 12:48:45.708277+00:00, deleted:False>, <Playlist id:5, name:second, date_created:2012-08-06 21:19:33.050187+00:00, deleted:False>]
のスキーマモデルPlaylist
は
class Playlist(models.Model):
name = models.CharField(max_length=30)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
deleted = models.BooleanField(default=False)
それらをfirebugにログインすると、次のように表示されます
Playlist objectPlaylist objectPlaylist objectPlaylist object
これらのオブジェクトを jQuery で読み取るにはどうすればよいですか?