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?

1 Answer 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.