Re: User to Model relationship- implement a "like" feature on a Model

2014-08-26 Thread shmengie
models.py: class Like(models.Model): event = models.ForeignKey(Event) user = model.ForeignKey(User) class Meta: unique_together = ("event", "user") Now you can count Likes for a given event likes =

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread amarshall
Thanks ! I'll get to work on that and see how it goes! On Monday, August 25, 2014 8:26:35 PM UTC-4, Tim Chase wrote: > > On 2014-08-25 17:00, amarshall wrote: > > Hmm, That may work. I should have also noted one thing. I'm > > actually using Django as the backend for mobile application. Both >

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread Tim Chase
On 2014-08-25 17:00, amarshall wrote: > 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

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread amarshall
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

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread Mario Gudelj
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"

User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread amarshall
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 =