On 8/23/07, altahay <[EMAIL PROTECTED]> wrote: > > Hello to all, > > I know my question could be a bit silly but... I dont know how to do > it. Do anybody know how to do arithmetic operations in a templete?
Generally speaking - you don't. This is by design. Django tries very hard to prevent you from putting logic into a template. Logic and calculations belong in the view; the template shouldn't have any need for calculations. If you maintain this strict separation, it becomes possible to change the template without altering the view, and vice versa. To this end, the Django template language is not, nor will ever be a Turing complete programming language. We have specifically avoided adding arithmetic operations, etc. There are a few very basic math filters - but they exist only to support display-based calculations. How many pixels wide does this DIV need to be, given the size of its component parts - that sort of thing. If you think you need to do arithmetic in a template - think really hard about what you are doing. Are you actually trying to change a display feature, or are you changing the information that is being displayed? If it is the latter, the calculation should be in the view. 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---