I’m new to django and can’t find the way to refresh only the div and that the div shows me current rating with stars. My idea is that user can see average rating and rate so
First, copy the code inside the and save it to another file. Lets say,
rating.html
Now in your page, it will be,
your.html
............
{% include 'rating.html' %}
............
Then, create new view
and new url
for rating.html
urls.py
url(r'^rating/$', 'rating', name='rating'),
views.py
def rating(request):
//rating object here
return render(request, 'rating.html', {
//call rating object variable here
})
Finally, in your ajax
.........
$.ajax({
url: vote_url,
success: function(){
alert('Vote successful!);
$("#rating").load("/app_name/rating/");
},
});
...........