Hmm, That may work. I should have also noted one thing. I'm actually using 
Django as the backend for mobile application. Both *Android* and iOS. So 
I'd like to do something like this, in the simplest matter:

pseudocode:
  
      get information from the server.
      if this_user HAS NOT "liked"  this event ,
              event_likes_count += 1
     else
          keep the like count the same. make like button inactive
         

On Monday, August 25, 2014 6:57:09 PM UTC-4, somecallitblues wrote:
>
> The other way would be to simply wire a cookie to user's browser and use 
> js to disable the the like button if the cookie is present if you can get 
> away with it. Not sure if you need to store that info against the user to 
> see which items they liked...
> On 26/08/2014 8:41 am, "amarshall" <adria...@gmail.com <javascript:>> 
> wrote:
>
>> Hi, 
>>
>>    I'm trying to implement likes on a Model in which 1 user will be able 
>> to like an a model (named "event") "once" and only once. 
>>
>> so, I have a model like this: 
>>
>> class Event(models.Model):
>>
>>     user = models.ForeignKey(User)
>>     .         #other fields
>>     .
>>     likes = models.PositiveIntegerField(default=0,null=True)
>>
>>
>>
>>
>> How do I implement it so that only one user can "like" an event (increase 
>> by 1) ? Brainstorming I'm thinking should I make a new class called "like" 
>> and have it have "Event" as a foreign key and a oneToOne relationship with 
>> User ? not really sure how to go about doing this.
>>
>> class Like(models.Model):
>>         
>>        event = models.ForeignKey(Event)
>>        
>>        user = model.ManyToMany(User) 
>>        user_liked = models.BooleanField(default=false)
>>        total_count = models.PositiveIntegerField(default=0)
>>
>>
>> ?   Then when an event is created a "Like" is created as well ? This may 
>> be doing to much and there's a simpler way?
>>
>>
>>        
>>
>> -- 
>> 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...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> 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/05ade3fc-f182-49be-a7d3-043fad68131b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/05ade3fc-f182-49be-a7d3-043fad68131b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/52b64696-a720-4c6e-99a1-f4ea5b97acdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to