Django

Code

Ticket #2841 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

Validator documentation is contradictory regarding required fields

Reported by: dave AT avaragado.org Assigned to: mtredinnick
Milestone: Component: Validators
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

From the validators documentation:

"After a form has been submitted, Django first checks to see that all the required fields are present and non-empty. For each field that passes that test and if the form submission contained data for that field, all the validators for that field are called in turn"

The first sentence implies that required field checking is a separate step, before any validators are run. The second is what actually appears to happen: is_required check, then validators, for each field in turn.

It might be worth rewording to clarify. Perhaps:

"After a form has been submitted, Django validates each field in turn. First, if the field is required, Django checks that it is present and non-empty. Then, if that test passes and the form submission contained data for that field, all the validators for that field are called in turn."

It would also be worth mentioning that custom validators can't rely on ALL required fields in the form being present when the validator runs: only the field to which the validator is attached.

Alternatively, make is_required checking truly a separate initial step and change the documentation differently...

Attachments

forms.diff (1.0 kB) - added by Simon G. <dev@simon.net.nz> on 03/26/07 05:53:19.

Change History

09/28/06 19:59:54 changed by mtredinnick

  • owner changed from adrian to mtredinnick.

You're right. The first sentence is ambiguous (you just have to read it with my twist of mind). I'll fix that.

Let's just address the documentation issue here. The requirement checking vs. validation pass isn't going to change right now, since it's something we need to look at in the manipulator rewrite, so let's leave it until then.

03/26/07 05:53:19 changed by Simon G. <dev@simon.net.nz>

  • attachment forms.diff added.

03/26/07 05:53:38 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

03/31/07 20:25:01 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [4886]) Fixed #2841 -- Clarified documentation on procedure for field validation. Thanks, dave@avaragado.org.


Add/Change #2841 (Validator documentation is contradictory regarding required fields)




Change Properties
Action