Comparing Python Date and Datetime / Django

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!


Next entry

Previous entry

Similar entries


Comments

Comments are closed.


Pingbacks

Pingbacks are open.


Trackbacks

Trackback URL