Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14708 - Document available keys for form field error messages;…

… thanks adamv.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15080 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b0ecab516f7842d53cd55f2461f24ad79fa28282 1 parent 4919aae
Tim Graham authored December 28, 2010

Showing 1 changed file with 21 additions and 1 deletion. Show diff stats Hide diff stats

  1. 22  docs/ref/forms/fields.txt
22  docs/ref/forms/fields.txt
@@ -340,6 +340,9 @@ Has two optional arguments for validation:
340 340
     * Validates that the given value exists in the list of choices.
341 341
     * Error message keys: ``required``, ``invalid_choice``
342 342
 
  343
+The ``invalid_choice`` error message may contain ``%(value)s``, which will be
  344
+replaced with the selected choice.
  345
+
343 346
 Takes one extra required argument:
344 347
 
345 348
 .. attribute:: ChoiceField.choices
@@ -449,6 +452,9 @@ If no ``input_formats`` argument is provided, the default input formats are::
449 452
       ``min_value``, ``max_digits``, ``max_decimal_places``,
450 453
       ``max_whole_digits``
451 454
 
  455
+The ``max_value`` and ``min_value`` error messages may contain
  456
+``%(limit_value)s``, which will be substituted by the appropriate limit.
  457
+
452 458
 Takes four optional arguments:
453 459
 
454 460
 .. attribute:: DecimalField.max_value
@@ -497,7 +503,8 @@ given length.
497 503
     * Normalizes to: An ``UploadedFile`` object that wraps the file content
498 504
       and file name into a single object.
499 505
     * Validates that non-empty file data has been bound to the form.
500  
-    * Error message keys: ``required``, ``invalid``, ``missing``, ``empty``
  506
+    * Error message keys: ``required``, ``invalid``, ``missing``, ``empty``,
  507
+      ``max_length``
501 508
 
502 509
 To learn more about the ``UploadedFile`` object, see the :doc:`file uploads
503 510
 documentation </topics/http/file-uploads>`.
@@ -505,6 +512,10 @@ documentation </topics/http/file-uploads>`.
505 512
 When you use a ``FileField`` in a form, you must also remember to
506 513
 :ref:`bind the file data to the form <binding-uploaded-files>`.
507 514
 
  515
+The ``max_length`` error refers to the length of the filename. In the error
  516
+message for that key, ``%(max)d`` will be replaced with the maximum filename
  517
+length and ``%(length)d`` will be replaced with the current filename length.
  518
+
508 519
 ``FilePathField``
509 520
 ~~~~~~~~~~~~~~~~~
510 521
 
@@ -583,6 +594,9 @@ When you use an ``ImageField`` on a form, you must also remember to
583 594
     * Error message keys: ``required``, ``invalid``, ``max_value``,
584 595
       ``min_value``
585 596
 
  597
+The ``max_value`` and ``min_value`` error messages may contain
  598
+``%(limit_value)s``, which will be substituted by the appropriate limit.
  599
+
586 600
 Takes two optional arguments for validation:
587 601
 
588 602
 .. attribute:: IntegerField.max_value
@@ -614,6 +628,9 @@ Takes two optional arguments for validation:
614 628
       of choices.
615 629
     * Error message keys: ``required``, ``invalid_choice``, ``invalid_list``
616 630
 
  631
+The ``invalid_choice`` error message may contain ``%(value)s``, which will be
  632
+replaced with the selected choice.
  633
+
617 634
 Takes one extra required argument, ``choices``, as for ``ChoiceField``.
618 635
 
619 636
 ``TypedMultipleChoiceField``
@@ -632,6 +649,9 @@ takes two extra arguments, ``coerce`` and ``empty_value``.
632 649
       coerced.
633 650
     * Error message keys: ``required``, ``invalid_choice``
634 651
 
  652
+The ``invalid_choice`` error message may contain ``%(value)s``, which will be
  653
+replaced with the selected choice.
  654
+
635 655
 Takes two extra arguments, ``coerce`` and ``empty_value``, as for ``TypedChoiceField``.
636 656
 
637 657
 ``NullBooleanField``

0 notes on commit b0ecab5

Please sign in to comment.
Something went wrong with that request. Please try again.