The following query returns to me the 3 most upcoming EventDate's. I need to refine this query so that it will not return more than one EventDate for a particular Event. My query and models are shown below.
def build_upcoming_shows(parser, tokens): return UpcomingShowsNode() class UpcomingShowsNode(Node): def render(self, context): results = EventDate.objects.select_related(depth=1).filter(event__archive_datetime__gt = datetime.now).order_by('datetime').distinct()[:3] #results = Event.objects.filter(archive_datetime__gt = datetime.now).order_by('archive_datetime').distinct()[:3] context['upcoming_shows'] = results return '' register.tag('get_upcoming_shows', build_upcoming_shows) MODELS: class Event(models.Model): name = models.CharField(max_length=200, help_text="Please make sure to not use any special characters copied from a text editor in the title. If you need a quote or apostrophe, please type it in manually.") event_type = models.ForeignKey(EventType) link = models.URLField(blank=True) description = models.TextField(blank=True) picture = models.ImageField(upload_to='images/', blank=True) archive_datetime = models.DateTimeField(help_text="This is the date the event will become archived. Date's are in YYYY-MM-DD format. Times are given on the 24 hour clock.") acomment = models.TextField(help_text="This is for administrative use only and will not be displayed on the public page.", blank=True) class Admin: list_display = ('name',) search_fields = ('name',) js = ['/media/admin/js/tiny_mce/tiny_mce.js','/media/ admin/js/tiny_mce/textareas.js'] def __str__(self): return self.name class EventDate(models.Model): event = models.ForeignKey(Event, edit_inline = models.TABULAR, num_in_admin=8, num_extra_on_change=3) datetime = models.DateTimeField(core=True) ordering = ['-datetime'] class Admin: pass def __str__(self): return str(self.datetime) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---