Opened 9 years ago

Closed 9 years ago

#26259 closed New feature (wontfix)

Form.cleaned_data should call is_valid() if necessary

Reported by: Thomas Güttler Owned by: nobody
Component: Forms Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We stumbled over this code:

    form.is_valid()
    if form.cleaned_data.get('cancel'):
        ...

We did not understand why form.is_valid() is necessary.

It seems that form.cleaned_data is not a property, you need to call is_valid() first.

It would be nice if Form.cleaned_data is be a property, this way the following code would just work:

    if form.cleaned_data.get('cancel'):
        ...

Change History (1)

comment:1 by Tim Graham, 9 years ago

Component: UncategorizedForms
Resolution: wontfix
Status: newclosed
Summary: Form.cleaned_data should be a propertyForm.cleaned_data should call is_valid() if necessary
Type: UncategorizedNew feature

I don't think an implicit call to is_valid() is a good idea. Most of the time, you do want different handling for valid and invalid forms. Of course, you could write your own subclass of Form which has the behavior you desire.

Feel free to raise the idea on the DevelopersMailingList for other opinions.

Note: See TracTickets for help on using tickets.
Back to Top