mirror of
https://github.com/django/django.git
synced 2025-11-19 11:15:44 +00:00
Fixed #24920 -- Added support for DecimalField with no precision.
Thanks Lily for the review.
This commit is contained in:
parent
5c60763561
commit
f21882a68a
16 changed files with 205 additions and 78 deletions
|
|
@ -862,16 +862,22 @@ A fixed-precision decimal number, represented in Python by a
|
|||
:class:`~decimal.Decimal` instance. It validates the input using
|
||||
:class:`~django.core.validators.DecimalValidator`.
|
||||
|
||||
Has the following **required** arguments:
|
||||
Has the following arguments:
|
||||
|
||||
.. attribute:: DecimalField.max_digits
|
||||
|
||||
The maximum number of digits allowed in the number. Note that this number
|
||||
must be greater than or equal to ``decimal_places``.
|
||||
must be greater than or equal to ``decimal_places``. It's always required
|
||||
on MySQL because this database doesn't support numeric fields with no
|
||||
precision. It's also required for all database backends when
|
||||
:attr:`~DecimalField.decimal_places` is provided.
|
||||
|
||||
.. attribute:: DecimalField.decimal_places
|
||||
|
||||
The number of decimal places to store with the number.
|
||||
The number of decimal places to store with the number. It's always required
|
||||
on MySQL because this database doesn't support numeric fields with no
|
||||
precision. It's also required for all database backends when
|
||||
:attr:`~DecimalField.max_digits` is provided.
|
||||
|
||||
For example, to store numbers up to ``999.99`` with a resolution of 2 decimal
|
||||
places, you'd use::
|
||||
|
|
@ -895,6 +901,11 @@ when :attr:`~django.forms.Field.localize` is ``False`` or
|
|||
should also be aware of :ref:`SQLite limitations <sqlite-decimal-handling>`
|
||||
of decimal fields.
|
||||
|
||||
.. versionchanged:: 6.1
|
||||
|
||||
Support for ``DecimalField`` with no precision was added on Oracle,
|
||||
PostgreSQL, and SQLite.
|
||||
|
||||
``DurationField``
|
||||
-----------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue