On Wed, 2007-03-07 at 22:45 -0500, Jay Parlar wrote: [...] > I'm not quite understanding part of your first paragraph though: "I > would create a method on the model that takes a date (what you are > really interested in is the month and year) and returns a list of the > dates in that month when this event occurs" > > If the model is taking a date, then what is "this event"? Part of the > goal would be to determine *which* events occur in a given month. The > second step would be to figure out all the times those events do > occur. > > Given all the events that do occur in a given month, the rest of your > steps make sense, but I'm still not sure how I'd find that initial > list of events.
Sorry, I skipped the first step in the reasoning because I thought it was obvious. My bad. Except for events that repeat only yearly, every single one of your events is going to occur at least once in any given month. The only exceptions will be things like events with monthly repetition on the 30th of the month and where you're considering the month of February. But that case occurs infrequently enough that you can ignore it. So, your initial list is *every event*. Then you have a method on the Event model that converts that single event + a month and year (i.e. a date) into a list of events on particular dates in that month. The slight improvement here is to select every event except yearly ones and then treat yearly recurrences as special. Which approach is best depends on how common yearly events are. Iterate over your set of events, calling the special method and have that method return a list of (date, title) tuples, for example. Then merge those lists (iterate and merge in a single list comprehension), sort the list and you're ready to put them on a calendar. Is that clearer? 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 [email protected] 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 -~----------~----~----~----~------~----~------~--~---

