diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-21 01:29:58 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-05-21 01:29:58 +0000 |
| commit | 92c35a0617836b09aef3b6909579ee368004969b (patch) | |
| tree | cd5a12f945bf105a53a0346f84c7d5ca6fc7f11f /docs | |
| parent | 03966f077b8f87d6a59366dedc80fcf1f935e2d3 (diff) | |
Fixed #2365, #3324 -- Renamed FloatField to DecimalField and changed the code
to return Decimal instances in Python for this field. Backwards incompatible
change.
Added a real FloatField (stores floats in the database) and support for
FloatField and DecimalField in newforms (analogous to IntegerField).
Included decimal.py module (as django.utils._decimal) from Python 2.4. This is
license compatible with Django and included for Python 2.3 compatibility only.
Large portions of this work are based on patches from Andy Durdin and Jorge
Gajon.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5302 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/forms.txt | 7 | ||||
| -rw-r--r-- | docs/model-api.txt | 48 | ||||
| -rw-r--r-- | docs/newforms.txt | 8 |
3 files changed, 39 insertions, 24 deletions
diff --git a/docs/forms.txt b/docs/forms.txt index 329e84a1b1..f6cb55a3f6 100644 --- a/docs/forms.txt +++ b/docs/forms.txt @@ -567,6 +567,7 @@ check for the given property: * isValidANSIDate * isValidANSITime * isValidEmail + * isValidFloat * isValidImage * isValidImageURL * isValidPhone @@ -664,10 +665,10 @@ fails. If no message is passed in, a default message is used. Takes an integer argument and when called as a validator, checks that the field being validated is a power of the integer. -``IsValidFloat`` +``IsValidDecimal`` Takes a maximum number of digits and number of decimal places (in that - order) and validates whether the field is a float with less than the - maximum number of digits and decimal place. + order) and validates whether the field is a decimal with no more than the + maximum number of digits and decimal places. ``MatchesRegularExpression`` Takes a regular expression (a string) as a parameter and validates the diff --git a/docs/model-api.txt b/docs/model-api.txt index 1125d2810f..f42078eafb 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -184,6 +184,33 @@ A date and time field. Takes the same extra options as ``DateField``. The admin represents this as two ``<input type="text">`` fields, with JavaScript shortcuts. +``DecimalField`` +~~~~~~~~~~~~~~ + +A fixed-precision decimal number, represented in Python by a ``Decimal`` instance. +Has two **required** arguments: + + ====================== =================================================== + Argument Description + ====================== =================================================== + ``max_digits`` The maximum number of digits allowed in the number. + + ``decimal_places`` The number of decimal places to store with the + number. + ====================== =================================================== + +For example, to store numbers up to 999 with a resolution of 2 decimal places, +you'd use:: + + models.DecimalField(..., max_digits=5, decimal_places=2) + +And to store numbers up to approximately one billion with a resolution of 10 +decimal places:: + + models.DecimalField(..., max_digits=19, decimal_places=10) + +The admin represents this as an ``<input type="text">`` (a single-line input). + ``EmailField`` ~~~~~~~~~~~~~~ @@ -290,26 +317,7 @@ because the ``match`` applies to the base filename (``foo.gif`` and ``FloatField`` ~~~~~~~~~~~~~~ -A floating-point number. Has two **required** arguments: - - ====================== =================================================== - Argument Description - ====================== =================================================== - ``max_digits`` The maximum number of digits allowed in the number. - - ``decimal_places`` The number of decimal places to store with the - number. - ====================== =================================================== - -For example, to store numbers up to 999 with a resolution of 2 decimal places, -you'd use:: - - models.FloatField(..., max_digits=5, decimal_places=2) - -And to store numbers up to approximately one billion with a resolution of 10 -decimal places:: - - models.FloatField(..., max_digits=19, decimal_places=10) +A floating-point number represented in Python by a ``float`` instance. The admin represents this as an ``<input type="text">`` (a single-line input). diff --git a/docs/newforms.txt b/docs/newforms.txt index 5516f60683..7ec4e9560c 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -1253,10 +1253,11 @@ the full list of conversions: ``CommaSeparatedIntegerField`` ``CharField`` ``DateField`` ``DateField`` ``DateTimeField`` ``DateTimeField`` + ``DecimalField`` ``DecimalField`` ``EmailField`` ``EmailField`` ``FileField`` ``CharField`` ``FilePathField`` ``CharField`` - ``FloatField`` ``CharField`` + ``FloatField`` ``FloatField`` ``ForeignKey`` ``ModelChoiceField`` (see below) ``ImageField`` ``CharField`` ``IntegerField`` ``IntegerField`` @@ -1281,6 +1282,11 @@ the full list of conversions: ``XMLField`` ``CharField`` with ``widget=Textarea`` =============================== ======================================== + +.. note:: + The ``FloatField`` form field and ``DecimalField`` model and form fields + are new in the development version. + As you might expect, the ``ForeignKey`` and ``ManyToManyField`` model field types are special cases: |
