There's numerous time where I found myself wishing for type casting
filters in templates..

For example, the following won't work because one is a string and the
other is an integer:

{% if request.GET.year == object.date.year %}
 ...
{% endif %}

So when I need to compare a string with an int without having to write
custom filters, I use this hack:

{% if request.GET.year == object.date.year|slugify %}
 ...
{% endif %}

While it works, it ain't pretty.

It would be nice if we could simply do this:

{% if request.GET.year == object.date.year|string %}
 ...
{% endif %}

Or this:


{% if request.GET.year|int == object.date.year %}
 ...
{% endif %}

Am I the only one who gets in such situations ? Is there an interest
for such filters ?

If so I might propose a patch..

Regards

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

Reply via email to