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 last_modified date in my template, but only if
it's different from the creation date.
(in other words: don't let the template display the last_modified
date, if the post hasn't been modified yet)
The following code in the template should work:
{% ifnotequal post.created post.last_modified %}
Last modified at {{ post.last_modified|date:"l d M Y" }}
{{ post.last_modified|date:"H.G" }}u
{% endifnotequal %}
But it doesn't, because Django saves the timestamps with microsecond
precision, e.g. for a newly created post:
Created: 2009-05-30 19:09:25.790253
Last_modified: 2009-05-30 19:09:25.790280
I've tried doing something like:
{% ifnotequal topic.created|date:"l d M Y" topic.last_updated|date:"l
d M Y" %}
But of course, that won't work.
Is there any way I could compare two timestamps, without that high
level of precision?
Thanks,
Kevin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---