On Jun 18, 9:32 pm, mw <[EMAIL PROTECTED]> wrote:
> I was thinking about ways to list some objects that are close to the
> current date.  I could do this using datetime and just subtract the
> two dates, but this seems like something that has probably been done
> before.  It seems like there would be a more Django way of doing it
> than me doing it manually.

I think python's datetime is pretty straightforward.

At the top of your views.py:

from datetime import datetime
from datetime import timedelta

For your specific view, construct your time window:

  current_time = datetime.now()
  window_time = timedelta(hours=10)
  events_time = current_time - window_time
  week_time = current_time + timedelta(days=15)



I do this for a calendar app to show other events in the few days
before and after the event your looking at. Pretty sweet for concerts
when you want to make sure you don't blow your budget on the wrong
show.



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