Cleaning form data in Django

11,332

You can define clean_FIELD_NAME() methods which can validate and alter data, as documented here: http://docs.djangoproject.com/en/dev/ref/forms/validation/#ref-forms-validation

Share:
11,332
Aether McLoud
Author by

Aether McLoud

Updated on June 19, 2022

Comments

  • Aether McLoud
    Aether McLoud almost 2 years

    How can i clean and modify data from a form in django. I would like to define it on a per field basis for each model, much like using ModelForms.

    What I want to achieve is automatically remove leading and trailing spaces from defined fields, or turn a title (from one field) into a slug (which would be another field).

  • user1066101
    user1066101 over 15 years
    Also the overall clean() method of the Form.