I am trying to figure out the best place to matchup Events and Dates when 
rendering a 'basic calendar.'

Events: 0, 1, more per date.
Dates: a list of all the dates in a month, so about 30 - one for each day.

# views.py
class Event(models.Model):
     title = models.CharField(maxlength=255)
     eventdate = models.DateField()
     description = models.TextField(blank=True)
     def __str__(self):
         return "%(ed)s  %(t)s" % {'t':self.title, 'ed':self.eventdate }

# models.py
     # 6=Week starts on Sunday
     c=calendar.Calendar(6)

     # get all the dates that will be displaied,
     # including the tail and head of previous/next months.
     dates=c.monthdatescalendar(year, month)

     # get Events from the DB that are in the specified month.
     object_list = 
Event.objects.filter(eventdate__range=(dates[0][0],dates[-1][-1]))

Now that I have dates and object_list, I can either pass both off to the 
template and let it put event on the days as it builds,

or in my view: create a list of 'day objects', one for each day, and hang the 
set of events for that day off each.

I thought it would be easy enough to do it in the template, but I am starting 
to 
have 2nd thoughts.

Carl K

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to