1

I have a clean function for my form, and in it I have the below:

tags = cleaned_data.get("tags")
logger.info('got to clean function ' + str(tags))

When I output the tags value, I see: [ '1', '2', '3' ]. In my template, when I want to recreate the html for it, I have a template_tag:

@register.simple_tag
def generate_tags(tags):
    print str(tags)
    # Code to produce the html

and I'm calling it via: {% generate_tags form.tags %}.

However, when I finish the print command in the template function im getting:

<input type="hidden" name="event_tags" value="3" id="id_event_tags_0" />

Why isn't it giving me the array as I was seeing in the clean function?? Is there a way for me to get the array before the clean function is called?

4

1 回答 1

1

Clearly this is not documented anywhere. For anybody else stuck on the same problem, if you have a form object, you can do:

form['field_name'].value()

This gives the value before it is cleaned or validated.

于 2012-07-29T20:37:15.907 回答