From 3fa3de54152a6b7a67de05ff4ff6fb122c9246e2 Mon Sep 17 00:00:00 2001 From: Jeff <3820914+jeffyancey@users.noreply.github.com> Date: Thu, 16 Aug 2018 17:03:28 -0400 Subject: Fixed #29646 -- Doc'd the validators that each model and form field uses. --- docs/ref/models/fields.txt | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'docs/ref/models') diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 94e299846d..4abb4dddaa 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -414,7 +414,7 @@ guaranteed to fit numbers from ``-9223372036854775808`` to ``BinaryField`` --------------- -.. class:: BinaryField(**options) +.. class:: BinaryField(max_length=None, **options) A field to store raw binary data. It only supports ``bytes`` assignment. Be aware that this field has limited functionality. For example, it is not possible @@ -427,6 +427,14 @@ case it can't be included in a :class:`~django.forms.ModelForm`. Older versions don't allow setting ``editable`` to ``True``. +``BinaryField`` has one extra optional argument: + +.. attribute:: BinaryField.max_length + + The maximum length (in characters) of the field. The maximum length is + enforced in Django's validation using + :class:`~django.core.validators.MaxLengthValidator`. + .. admonition:: Abusing ``BinaryField`` Although you might think about storing files in the database, consider that @@ -468,7 +476,8 @@ The default form widget for this field is a :class:`~django.forms.TextInput`. .. attribute:: CharField.max_length The maximum length (in characters) of the field. The max_length is enforced - at the database level and in Django's validation. + at the database level and in Django's validation using + :class:`~django.core.validators.MaxLengthValidator`. .. note:: @@ -551,7 +560,10 @@ The default form widget for this field is a single .. class:: DecimalField(max_digits=None, decimal_places=None, **options) A fixed-precision decimal number, represented in Python by a -:class:`~decimal.Decimal` instance. Has two **required** arguments: +:class:`~decimal.Decimal` instance. It validates the input using +:class:`~django.core.validators.DecimalValidator`. + +Has two **required** arguments: .. attribute:: DecimalField.max_digits @@ -603,8 +615,8 @@ SECOND(6)``. Otherwise a ``bigint`` of microseconds is used. .. class:: EmailField(max_length=254, **options) -A :class:`CharField` that checks that the value is a valid email address. It -uses :class:`~django.core.validators.EmailValidator` to validate the input. +A :class:`CharField` that checks that the value is a valid email address using +:class:`~django.core.validators.EmailValidator`. ``FileField`` ------------- @@ -969,9 +981,15 @@ The default form widget for this field is a .. class:: IntegerField(**options) An integer. Values from ``-2147483648`` to ``2147483647`` are safe in all -databases supported by Django. The default form widget for this field is a -:class:`~django.forms.NumberInput` when :attr:`~django.forms.Field.localize` -is ``False`` or :class:`~django.forms.TextInput` otherwise. +databases supported by Django. + +It uses :class:`~django.core.validators.MinValueValidator` and +:class:`~django.core.validators.MaxValueValidator` to validate the input based +on the values that the default database supports. + +The default form widget for this field is a :class:`~django.forms.NumberInput` +when :attr:`~django.forms.Field.localize` is ``False`` or +:class:`~django.forms.TextInput` otherwise. ``GenericIPAddressField`` ------------------------- @@ -1050,6 +1068,9 @@ It is often useful to automatically prepopulate a SlugField based on the value of some other value. You can do this automatically in the admin using :attr:`~django.contrib.admin.ModelAdmin.prepopulated_fields`. +It uses :class:`~django.core.validators.validate_slug` or +:class:`~django.core.validators.validate_unicode_slug` for validation. + .. attribute:: SlugField.allow_unicode If ``True``, the field accepts Unicode letters in addition to ASCII @@ -1093,7 +1114,8 @@ The admin adds some JavaScript shortcuts. .. class:: URLField(max_length=200, **options) -A :class:`CharField` for a URL. +A :class:`CharField` for a URL, validated by +:class:`~django.core.validators.URLValidator`. The default form widget for this field is a :class:`~django.forms.TextInput`. -- cgit v1.3