I’m trying to find if two DateTimeFields are greater than 2 days difference in a template. Is this possible to do in a template?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no built-in way to do this inside a template. You could first calculate the day difference in the view, but I doesn’t sound like that’s what you want.
The easiest way to do this inside a template would be to write a custom template filter. (Custom template filters are quite a bit easier than creating custom tags, by the way.)
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-filters