Thank you all, I will check documentation for using Django with AJAX.

Regards,
Karino KANG

Le jeudi 8 mai 2014 14:08:30 UTC+2, Stodge a écrit :
>
> Yes it is possible - think of the actions that need to take place.
>
>  * The user clicks the button in the browser.
>  * The browser sends an Ajax request to Django
>  * The Django view processes the Ajax request, updates the database and 
> sends a response to the browser
>
> These are web fundamentals and I think you need to do some reading on the 
> basic server/client architecture.
>
> On Thursday, 8 May 2014 07:35:22 UTC-4, Karino Kang wrote:
>>
>> Dear all,
>>
>> I'm a relatively new user of Django and I'm struggling to do something 
>> I'm not sure is possible with Django.
>>
>> I wanted to develop a "like" app which act pretty much like the facebook 
>> "like" except that you can dislike.
>>
>> My main problem is that I want to have a button or image for liking and 
>> disliking and I want to execute an action only in the database.
>>
>> for example, for the like, I would have something in the template like :
>>
>> <a href='#'><img src="like.png" /></a>
>>
>> And I would have a python function defined somewhere in the app which 
>> would be the following :
>>
>> def like(model):
>>     like_object = Like.objects.get(model=model, model_id=model_id)
>>
>>     if like_object:
>>         like_object = Like(model=model, model_id=model_id, like_count=1)
>>
>>     like_object.like_count = like_count + 1
>>     like_object.save()
>>
>>
>> I want this action to be executed when I click on the image like.png but 
>> I don't want the page to be change. There will be a like count displayed on 
>> the page but it will be updated using javascript.
>>
>> Is this possible with Django?
>>
>> Regards,
>> Karino KANG
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/308258ea-c860-4fd9-a03f-79b1dedc182f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to