Hello,

These are my models

class Event(models.Model):
    date = models.DateField(core=True)
    type = models.ForeignKey(EventType, limit_choices_to = {'useable':
True})
    ....

class Partner(models.Model):
    name = models.CharField(max_length=50)
    ....

class EventPartner(models.Model):
    event = models.ForeignKey(Event)
    partner = models.ForeignKey(Partner)
    relationtype = models.CharField(max_length=2,
choices=RELATIONTYPE_CHOICES)
    ...

I want to have all Partners from the last event.
Is there a simple query-solution with the django database-api? With a
standard-sql the solution is very easy, but I want to use django's
database api.

To get the last event I use:
Event.objects.latest('date')

To get a list of EventPartners i use:
Event.objects.latest('date').eventpartner_set.all()

But how do I get a list of my Partners? I tried a few things, but I
didn't find a solution. I need the Partner-list, because I want to use
a template, which expect a Partner-list. It would also be possible to
write another template for a EventPartner-list, but that's a bad
solution.

Regards
  Bernd


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to