On Thu, Dec 17, 2009 at 6:42 PM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Dec 17, 10:10 am, gganesh <ganesh....@gmail.com> wrote:
>> hi group,
>>  How to compare date field types in a template ,a have field due_on
>> taking DateField type .I have to compare to present date .I have tried
>> the following in vain ,please help
>> In a template
>> {% if enquiry.due_on >= datetime.datetime.today %} .....{% end if %}
>> and
>> {% if enquiry.due_on__gt datetime.datetime.today %} .....{% end if %}
>> both gives an error
>> It gives me an error like 'if' statement improperly formatted
>>
>> Thanks
>> ganesh
>
>
> Don't program by guessing. The documentation clearly states that
> template syntax is not Python, and goes on to list in detail the
> syntax of the {% if %} tag, which doesn't include anything that
> implies you could use anything like the examples you give above.
>
> If you need to do this comparison, you should probably try
> SmileyChris's smart_if template tag, which you can find on
> djangosnippets.org. However, a better way would be to define an
> 'is_due' method on your 'enquiry' model which does the comparison, and
> returns True or False, which you can then call directly from your
> template.

This point requires a little clarification - if you're using a very
recent trunk checkout of Django, the capabilities of "smart if" *are*
available. However, this is only on recent SVN checkout of trunk
Django - the stable 1.1 series doesn't include this feature.

Yours,
Russ Magee %-)

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to