On Nov 8, 4:49 pm, jim <[EMAIL PROTECTED]> wrote:
> I am writing some custom template filters. How does one transmit
> multiple arguments to a filter. eg.
>
> {{ form.errors|dynamicformfield:"pass",1,"firstname" }}
>
> my dynamicformfield filter has the following signature:
>
> def dynamicformfield(value, firstpart, midpart, lastpart):
>
> I always get a error saying that the filter expects 3 args and I am
> sending in only 1.

Filters always take either one or two arguments but not more. See:
http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters

Here's how you can pass in multiple parameters.

Change your filter function to take in just one real parameter that
multiplexes three comma-separated parameters:

def dynamicformfield(value, parts):
    firstpart, midpart, lastpart = parts.split(',')
    # you've got your three parameters now to run with

The filter usage would be:

{{ form.errors|dynamicformfield:"pass,1,firstname" }}

In other words, you specify all 3 parts as a single string with comma-
separated values that you can then demultiplex in your filter
function.






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