Hi Margie,

I'm not sure off the top of my head, but if memory serves me right,
template tags may not allow variable number of parameters.  I'd take a
look at the code from the {% url %} template tag, it's syntax allows
for multiple variables, but they're passed in a very particular way.
It's actually some very straightfoward but powerful code in the core
and a great place to start getting to konw djano a little better.
I've done some similar stuff to create template view requests (a more
rails way of thinking about things) as well as a tag for partial urls.

Cheers
Dan

On Sun, May 10, 2009 at 12:28 AM, Margie <margierogin...@yahoo.com> wrote:
>
> I want to write a templatetag that goes through a bunch of media and
> returns the media lines without duplicates, something like this
> (except I'm not removing duplicates here, not sure if the '+' is going
> do it for me or not).
>
> def form_media(*args):
>    finalFormMedia = Media()
>    for formMedia in args:
>        finalFormMedia += formMedia
>    return finalFormMedia
> register.simple_tag(form_media)
>
> When I try to use this tag with something like this
>
> {% form_media taskForm.media assignmentFormSet.media %}
>
> I get the error
>
> Exception Type:         TemplateSyntaxError
> Exception Value:
> form_media takes 0 arguments
>
> Anyone know how I do a tag with variable number of arguments?
>
> Margie
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to