Hi,
It always frustrates me when I must resort to custom filter to do
simple math to achieve some special-case markups (eg. applying a row
tag around 5 items max for a list of objects).
Do you think a math tag like this that I just published to
djangosnippets.org can be made into the default list
On May 3, 7:43 am, Russell Keith-Magee
wrote:
> This stems back to the design motivation of Django's template language
> -- you shouldn't be doing math in the template. Instead, you should be
> doing your math in the view, and providing the template with a
> pre-calculated result.
>
> So, my incli
> Holy god, not to be rude, but given that this is completely unreadable I'm
> even more -1 than I ever would have been on the basis of the principle of a
> dumber template language.
>
> Alex
My apologies. All that is doing is rendering the following result when
the URL is http://localhost:8001/?x
>
> Or, in a sane world:
>
> if x = {{ x }}, y = {{ y }}, {{ x }} + {{ y }} = {{ x_plus_y_res }}
> if x = {{ x }}, y = {{ y }}, {{ x }} * {{ y }} = {{ x_star_y_res }}
>
> and so on.
>
While it is a common consensus that logic should never be in the template,
the "solution" on the other hand is in
> Weird, I have missed this thread. But anyway, like sdcooke, that's
> also the way that we handle URLs in javascript.
> Attach a data attribute to the HTML node to which it applies, and read
> it from inside the javascript. It's clean.
>
> x:ajax-url="{% url accounts_ajax_edit_name %}">{% tr