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]>
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(
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
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
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]
5 matches
Mail list logo