Comparing Python Date and Datetime / Django

Posted by: scoopseven 13 years, 1 month ago

I'm always doing this, so some of you must be too. I'll compare a date field in with a datetime object in Python/DJango like this:
if self.start_date < datetime.datetime.now():
and I'll get:
type object 'datetime.datetime' has no attribute 'datetime'
Grrrr, this is super-annoying. Of course, it's a simple fix.
if self.start_date < date.today():
Yaaaaayyyyy!

Currently unrated


Recent Tweets

Recent Posts

Archive

2013
2012
2011
2010
2009
2008
2007
2006

Categories

Authors

Feeds

RSS / Atom