title: Django: How to get a time difference from the time post?
body: <p>Say I have a class in model</p>
  
  <pre><code> class Post(models.Model):
       time_posted = models.DateTimeField(auto_now_add=True, blank=True)
  
       def get_time_diff(self):
           timediff = timediff = datetime.datetime.now() - self.time_posted
           print timediff # this line is never executed
           return timediff
  </code></pre>
  
  <p>I defined a get_time_diff to get the time difference from the time when the Post is posted up to now, according to the document, the DateTimeField should be able to be converted to datetime automatically, is that correct? Why the print statement is never being run? How can you extract the time difference?</p>
  
  <p>Beside, if you get a time difference, is there an easy way to convert the time difference to an integer, like the number of seconds of the total time.</p>