Re: Need help filtering a queryset

2008-07-01 Thread Brandon Taylor
Thanks very much for the advice Brian. I'll definitely switch that up and try both approaches. I hadn't seen another way to get at a subset of objects other than: model_set.all but now I do, thanks to your example. Kind regards, Brandon On Jul 1, 12:28 pm, Brian Luft <[EMAIL PROTECTED]>

Re: Need help filtering a queryset

2008-07-01 Thread Brian Luft
Another approach would be to add a method to your events model. Name it something like "current_occurrences" and have it return the filtered occurrences. Ex: class event( models.Model ): ... def current_occurrences( self ): return self.occurrence_set.filter(

Re: Need help filtering a queryset

2008-07-01 Thread Brian Luft
Ok, you are asking for a list of events that have occurences on or after today's date. Then with each event instance you are asking for ALL occurence instances (event.occurrence_set.all). ALL means EVERY occurence associated with that event object. You haven't done anything to filter out

Re: Need help filtering a queryset

2008-07-01 Thread Brandon Taylor
I made a custom filter that tests for the date: import datetime from django import template register = template.Library() @register.filter('is_current') def isPast(occurrence): if occurrence.date >= datetime.datetime.today().date(): return True return False which works, but

Need help filtering a queryset

2008-07-01 Thread Brandon Taylor
Hi everyone, I have Events and Occurrences of an Event. Occurrence contains a foreign_key for the Event. In my template, I need to display the Event and Occurrences as such: Event Title One June 1, 2008 [times] July 23, 2008 [times] Event Title Two August 25, 2008 [times]