Hi all,

I have a page where users can rate a video, and in models.py I have a video
model with a 'rating' property. I wish to find out how I can AJAXify the
rating button on the page, so that if a user clicks on it, the button can
call a custom function and pass the video id (cannot call a view as that
would return an entire response). Am thinking of a function roughly as
follows:

from myproject.myapp.models import Video

def save_rating(video_id, rating):
    video = Video.objects.filter(pk=video_id)
    video.rating += rating
    video.save()
    return video.rating #* The rating label on the page would then be
updated with the returned rating.*

I would like to do this without using a view or doing a form POST or GET of
any kind. Any pointers?

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to