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+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/05ade3fc-f182-49be-a7d3-043fad68131b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to