Re: Arithmetic operations in a templete

2007-09-14 Thread [EMAIL PROTECTED]
On Sep 14, 12:46 pm, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > I'd have to take a look at how that tag was implemented, but I'd > likely start out with something horrific, like the attached patch :D Tsk, tsk. Bending the rules of the game a bit now, aren't we? :-) Again, yes, you could do

Re: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
On 9/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Sep 14, 11:29 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> > wrote: > > Pesky kids these days, with your music and your anticipation... > > :-) > > > I agree that what you propose here would be useful in the scenario > > you've describe

Re: Arithmetic operations in a templete

2007-09-14 Thread [EMAIL PROTECTED]
On Sep 14, 11:29 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > Pesky kids these days, with your music and your anticipation... :-) > I agree that what you propose here would be useful in the scenario > you've described. *Personally*, if I wanted something like that, I'd > just write a fun

Re: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
> Thanks for the response. But to be fair to you I must disclose that I > anticipated that someone would present this as an answer. I would have > added this discussion into the original but it was already a bit > long... :-) Pesky kids these days, with your music and your anticipation... > Now

Re: Arithmetic operations in a templete

2007-09-14 Thread [EMAIL PROTECTED]
On Sep 14, 9:31 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > > Template tags really are the best place to put display-specific logic > like this. The original problem specified (a custom button and > associated JavaScript for an object with the object's name in the > button's id) could be

Re: Arithmetic operations in a templete

2007-09-14 Thread Jonathan Buchanan
> However, simply dodging the question doesn't address the original point: > why does Django adhere to such a nannyish philosophy, and how do you > solve the problem I presented *within Django* in a reasonable way? > > Thanks and regards, > -scott anderson Template tags really are the best place

Re: Arithmetic operations in a templete

2007-09-14 Thread Scott Anderson
Yes, that's always the fall back, isn't it? I'll look at Jinja, as I didn't realize there was such a fork. Apparently I'm not the only one who thinks this way. I'm concerned with how well a solution like this tracks the Django release. However, simply dodging the question doesn't address the or

Re: Arithmetic operations in a templete

2007-09-14 Thread Scott Anderson
Thank you, but that's exactly what I said I *didn't* want to do, because it's silly. :-) Why should my *data model* know *anything* about the presentation? And what happens when I want a parrot row ID, or a parrot foo ID, or a parrot cheese ID? Suddenly I have a proliferation of things in my data

Re: Arithmetic operations in a templete

2007-09-14 Thread Samuel Adam
no, Scott, you should just do *this*: In your Parrot model, you could add a property that displays your DOM id. class Parrot(models.Model): # fields def _domid(self): return ''parrotButton-%s" % self.id domid = property(_domid) and use parrot.domid in your templates. On 14

Re: Arithmetic operations in a templete

2007-09-13 Thread James Bennett
On 9/13/07, Scott Anderson <[EMAIL PROTECTED]> wrote: > What I'm hoping, however, is that this missive was moot, because you'll > say, "no, Scott, you should just do *this*:", followed by an elegant and > reasonable solution that I, as a relative newcomer to Django, have not > yet considered. Here

Re: Arithmetic operations in a templete

2007-09-13 Thread Scott Anderson
On Thu, 2007-08-23 at 21:59 +0800, Russell Keith-Magee wrote: [...] > 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 calculatio

Re: Arithmetic operations in a templete

2007-08-23 Thread Russell Keith-Magee
On 8/23/07, *San* <[EMAIL PROTECTED]> wrote: > > So now, I passed in as dictionary data = { a: a_stuff, b: > b_stuff, ... } > where a_stuff and b_stuff is also a dictionary, a_stuff {a_max:9, > a_min:0, .. etc} > > when i use > {% for key,value in data.items %} > {{key}}, {{value}} > {%endfor%

Re: Arithmetic operations in a templete

2007-08-23 Thread *San*
So now, I passed in as dictionary data = { a: a_stuff, b: b_stuff, ... } where a_stuff and b_stuff is also a dictionary, a_stuff {a_max:9, a_min:0, .. etc} when i use {% for key,value in data.items %} {{key}}, {{value}} {%endfor%} it doesn't print anything, but when i do {% for key in data.i

Re: Arithmetic operations in a templete

2007-08-23 Thread Russell Keith-Magee
On 8/23/07, *San* <[EMAIL PROTECTED]> wrote: > > How to add suffix/prefix in a template? So if i passed in a list name- > [a,b,c,d] and a_max, b_max, etc from views.py. and I do something like > > {% for i in name %} > {{ i_max}} > {% endfor %} > > so I actually wants to print the value of a_m

Re: Arithmetic operations in a templete

2007-08-23 Thread *San*
hardcode the code instead of using for loop? On Aug 23, 11:01 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > 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? > > > {{elem}} > >

Re: Arithmetic operations in a templete

2007-08-23 Thread Russell Keith-Magee
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 trie

Re: Arithmetic operations in a templete

2007-08-23 Thread Tim Chase
> 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? > > {{elem}} > > what I want to do is something like {{ elem }} + 100 There's an "add" filter... http://www.djangopr

Re: Arithmetic operations in a templete

2007-08-23 Thread altahay
Sorry I wrote "templete" instead of "template" ... On 23 ago, 12:31, 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 templ

Arithmetic operations in a templete

2007-08-23 Thread altahay
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? {{elem}} what I want to do is something like {{ elem }} + 100 thank you in advance