summaryrefslogtreecommitdiff
path: root/docs/forms.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/forms.txt')
-rw-r--r--docs/forms.txt29
1 files changed, 14 insertions, 15 deletions
diff --git a/docs/forms.txt b/docs/forms.txt
index 0ffb0bdcb7..4a4ba37289 100644
--- a/docs/forms.txt
+++ b/docs/forms.txt
@@ -211,7 +211,7 @@ Below is the finished view::
def create_place(request):
manipulator = Place.AddManipulator()
- if request.POST:
+ if request.method == 'POST':
# If data was POSTed, we're trying to create a new Place.
new_data = request.POST.copy()
@@ -309,7 +309,7 @@ about editing an existing one? It's shockingly similar to creating a new one::
# Grab the Place object in question for future use.
place = manipulator.original_object
- if request.POST:
+ if request.method == 'POST':
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
if not errors:
@@ -337,8 +337,8 @@ The only real differences are:
object being edited.
* We set ``new_data`` based upon ``flatten_data()`` from the manipulator.
- ``flatten_data()`` takes the data from the original object under
- manipulation, and converts it into a data dictionary that can be used
+ ``flatten_data()`` takes the data from the original object under
+ manipulation, and converts it into a data dictionary that can be used
to populate form elements with the existing values for the object.
* The above example uses a different template, so create and edit can be
@@ -391,7 +391,7 @@ Here's a simple function that might drive the above form::
def contact_form(request):
manipulator = ContactManipulator()
- if request.POST:
+ if request.method == 'POST':
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
if not errors:
@@ -404,7 +404,7 @@ Here's a simple function that might drive the above form::
errors = new_data = {}
form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('contact_form.html', {'form': form})
-
+
``FileField`` and ``ImageField`` special cases
==============================================
@@ -481,15 +481,15 @@ the data being validated.
Also, because consistency in user interfaces is important, we strongly urge you
to put punctuation at the end of your validation messages.
-When Are Validators Called?
+When are validators called?
---------------------------
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 emphasised portion in the
+validators for that field are called in turn. The emphasized portion in the
last sentence is important: if a form field is not submitted (because it
-contains no data -- which is normal HTML behaviour), the validators are not
+contains no data -- which is normal HTML behavior), the validators are not
run against the field.
This feature is particularly important for models using
@@ -497,18 +497,17 @@ This feature is particularly important for models using
``forms.CheckBoxField``. If the checkbox is not selected, it will not
contribute to the form submission.
-If you would like your validator to *always* run, regardless of whether the
-field it is attached to contains any data, set the ``always_test`` attribute
-on the validator function. For example::
+If you would like your validator to run *always*, regardless of whether its
+attached field contains any data, set the ``always_test`` attribute on the
+validator function. For example::
def my_custom_validator(field_data, all_data):
# ...
-
my_custom_validator.always_test = True
This validator will always be executed for any field it is attached to.
-Ready-made Validators
+Ready-made validators
---------------------
Writing your own validator is not difficult, but there are some situations
@@ -580,7 +579,7 @@ fails. If no message is passed in, a default message is used.
``ValidateIfOtherFieldEquals``
Takes three parameters: ``other_field``, ``other_value`` and
``validator_list``, in that order. If ``other_field`` has a value of
- ``other_vaue``, then the validators in ``validator_list`` are all run
+ ``other_value``, then the validators in ``validator_list`` are all run
against the current field.
``RequiredIfOtherFieldNotGiven``