Hey everyone,
For my question I'll reference this model:
class Event(models.Model):
description = models.CharField(max_length=200)
event_date = models.DateTimeField()
def __unicode__(self):
return self.description
So basically I've got a bunch of events and when they take place.
What I would like to do in my index view is list the most recent 5
(for example) days which have(or had) events occuring and group the
events together by day.
i.e. this might look like:
Monday, September 24, 2007
--
1. event description #1 @ 6:00 AM
2. event description #2 @ 9:00
Friday, September 21, 2007
--
1. event description #1 @ 3:45 PM
.. and so on.
Using SQLite I can pull out the data I want using a query along the
line of:
select * from event where date(event_date) in
(
select date(event_date) from event
group by 1 order by 1 desc
limit 5
);
Now, the problem is
1) I'm not clear on how this query translates to Django's Database API
and
2) If it does translate, how can I print out the day (as shown above
in the example output) before each sequence of events? is this
something I can do within a template?
Any help and/or suggestions would be much appreciated ;-)
Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---