Getting object value for AJAX call using Dajaxice

被刻印的时光 ゝ 提交于 2019-12-02 13:14:08

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?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!