On 7/18/07, rogerdpack <[EMAIL PROTECTED]> wrote:
>
> I know that django support "method lookup, then hash member lookup
> then something" or what not, for template functions, but, my question
> is can you call a function (like a method) and pass it arbitrary
> parameters. {% function1 'a', 'b' %} type of thing.  Sorry if this is
> very newbie.
No, you can't. This is by design. The Django templating system is not
intended to be a programming language - it's a templating language.

The general Django philosophy is that you should be making your
function calls in your view, and passing them into the template as
part of the context. What you pass to the template is the data that
needs to be rendered, not the pieces that can be used to construct the
data that needs to be rendered. This keeps logic separated from
presentation, which means that your templates could be replaced
(changing the look of your application) without affecting the actual
data that will be presented.

However, there are some situations where it is appropriate to call a
function - for example, if you want to describe a presentation
operation that can be performed on some data. In these cases, you
might need to take a look at writing your own filter or template tag
to wrap the call to the function.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to