Glenn Tenney wrote:

>I was thinking about this too... in my case I've got an event starting
>date and ending date; in my views I want to be able to view based on
>criteria such as: hasn't happened yet, hasn't happened yet but will happen
>sometime this month / quarter / year, happened already this month/quarter/year.
>  
>
You mean displaying events like this:

| Event     | When      |
|-----------|-----------|
| Event 1   | today     |
| Event 2   | next week |

or selecting them from DB like "get all events starting next week"?

For display I wouldd give the Event model a method returning a string:

class Event(meta.Model):
    def when(self):
        if self.start_date == datetime.date():
            return 'today'
        if self.start_date == datetime.date()+timedelta(1):
            return 'tomorrow'
        ...

and for selecting just call events.get_list() with appropriate lookup 
args (http://www.djangoproject.com/documentation/db_api/#field-lookups)

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

Reply via email to