Hi, I have a question about the ORM.

If I have model class's:

class Event(models.Model):
    ....

class Ticket(models.Model):
    user = models.ForeignKey(User)
    event = models.ForeignKey(Event)
    .....

Then I have a user who has 2 tickets for the same event. If I have the
event object and want to see who has tickets I could do this:

an_event.ticket_set.all()

However that will result in a list of tickets which isn't necessarily
a unique list of people who have tickets to the event. In my example
the user has 2 tickets for one event so I would get two ticket objects
back in my query set. How do I limit the query set results to say
don't give me more than one ticket for the event per user.

Hope that makes sense?

-- 
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