On Thu, 2007-11-29 at 13:15 -0800, mamcxyz wrote: > I have a model of events and city. > > class Event(models.Model): > city = models.ForeignKey(City, blank=True, null=True, > core=True, verbose_name='ciudad') > > Then, I wanna let the user filter the events by city. But I don't > wanna show ALL the city, because a lot can't have events attached. So, > Exist New York, Miami & Chicago, but only chnicago have events. > > How get all the citys that have a event?
This should be close: City.objects.filter(event__pk__isnull=False).distinct() Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---