Reputation: 2486
I am having a weird problem.
I am running a django app and in one of my models I have a method to compare the time that the user gives and the time that is stored in the model db
So, for debugging purposes, I do this.
print self.start
print start
print self.start.time < start.time
And the output is:
2012-10-15 01:00:00+00:00
2012-10-22 01:01:00+00:00
False
HOW IS THIS POSSIBLE?!?!?!
I tried this in the django shell and in the python cli! Both give me True! With the same values.
Thanks guys.
Upvotes: 0
Views: 2315
Reputation: 179422
.time
is a method, not a property.
>>> import datetime
>>> a = datetime.datetime(2012, 10, 15, 1, 0, 0)
>>> a.time
<built-in method time of datetime.datetime object at 0x10049f508>
>>> a.time()
datetime.time(1, 0)
Therefore, the correct code would be if self.start.time() < start.time()
.
Upvotes: 6