Soga. Thank you very much.
Dae James
From: smcoll
Date: 2012-11-24 02:02
To: django-users
Subject: Re: How can I contrast two date-time type variables in template layer?
The 'timesince' filter (based on django.utils.timesince) doesn't return a datetime.timedelta object, but a formatted string. So it would be hard to compare the resulting string with anything. i think you're going to need to do one of the following:
On Friday, November 23, 2012 12:36:27 AM UTC-6, Dae_James wrote: --
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/EmGMHChbbLkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
- do the comparison in your view and add the result (true/false) to the context
- add the cutoff date to the context and compare the two datetime objects in your template
- write/find a templatetag or filter that can do what you need
On Friday, November 23, 2012 12:36:27 AM UTC-6, Dae_James wrote:
For example, art_time is a date-time type.As we know, {{ art_time|timesince }} return the time since art_time to now. However, I want to know how to judge whether the result is within 24 hours.Shortly, how to know whether art_time is today or the day before today in template layer?
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/EmGMHChbbLkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment