Re: Comparing timestamps

2009-05-31 Thread K.Berkhout
Already got it, it's: timedelta(seconds=1) In stead of: datetime.timedelta(seconds=1) On 31 mei, 14:29, "K.Berkhout" wrote: > Hmm, seems like the method always returns false, anybody knows what > goes wrong? > > On 31 mei, 12:29, "K.Berkhout" wrote: > >

Re: Comparing timestamps

2009-05-31 Thread K.Berkhout
Hmm, seems like the method always returns false, anybody knows what goes wrong? On 31 mei, 12:29, "K.Berkhout" wrote: > Thanks you very much for the solution, Damien! > > On 30 mei, 22:11, Damien GOMBAULT wrote: > > > Write a method is_modified in your

Re: Comparing timestamps

2009-05-31 Thread K.Berkhout
Thanks you very much for the solution, Damien! On 30 mei, 22:11, Damien GOMBAULT wrote: > Write a method is_modified in your Post model. > You can use datetime.timedelta to compare dates. > > def is_modified(self): >    second = datetime.timedelta(seconds=1) >    delta =

Re: Comparing timestamps

2009-05-30 Thread Damien GOMBAULT
Write a method is_modified in your Post model. You can use datetime.timedelta to compare dates. def is_modified(self): second = datetime.timedelta(seconds=1) delta = self.last_modified - self.created return delta >= second Then use it in your template : {% if post.is_modified %} {{

Comparing timestamps

2009-05-30 Thread K.Berkhout
Hi, Let's say I have the following post model: class Post(models.Model): text = models.TextField() created = models.DateTimeField(auto_now=False, auto_now_add=True) last_modified = models.DateTimeField(auto_now=True, auto_now_add=False) I want to display the