← Back to team overview

canonical-django team mailing list archive

Re: if date < now

 

Matthew Nuzum wrote:
> However I can't seem to find a way to do any kind of comparison short of
> pre-processing all the rows from the query to add a boolean for each row
> indicating that the event is near or in the past.

Django templates are designed to prevent having such "complex"
comparisons in them.

> Anyone have a tip that might help?
You have three choices:
- as you mentioned, preprocess before,
- add custom method to model object which will make the comparison,
- create custom template tag (it's really easy:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#shortcut-for-simple-tags)

Cheers
-- 
Łukasz Czyżykowski
Canonical Ltd.



References