I have a Song
model with a votes
attribute. I have a Vote as Favourite
button displayed below each Song
object. I want when a
Here's how you can update the votes. You don't need update_votes to be an ajax function.
def update_votes(song_id):
song = Song.objects.get(id=song_id)
song.votes += 1
song.save()
You can then call this function from within disable_button.
@dajaxice_register
def disable_button(request, song_id):
update_votes(song_id)
#disable the buttons
return #whatever
And are you sure you're using the right selector to disable your buttons?