mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #31777 -- Added support for database collations to Char/TextFields.
Thanks Simon Charette and Mariusz Felisiak for reviews.
This commit is contained in:
parent
ba6b32e5ef
commit
e387f191f7
25 changed files with 544 additions and 30 deletions
|
@ -593,20 +593,36 @@ For large amounts of text, use :class:`~django.db.models.TextField`.
|
|||
|
||||
The default form widget for this field is a :class:`~django.forms.TextInput`.
|
||||
|
||||
:class:`CharField` has one extra required argument:
|
||||
:class:`CharField` has two extra arguments:
|
||||
|
||||
.. 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 using
|
||||
Required. The maximum length (in characters) of the field. The max_length
|
||||
is enforced at the database level and in Django's validation using
|
||||
:class:`~django.core.validators.MaxLengthValidator`.
|
||||
|
||||
.. note::
|
||||
.. note::
|
||||
|
||||
If you are writing an application that must be portable to multiple
|
||||
database backends, you should be aware that there are restrictions on
|
||||
``max_length`` for some backends. Refer to the :doc:`database backend
|
||||
notes </ref/databases>` for details.
|
||||
If you are writing an application that must be portable to multiple
|
||||
database backends, you should be aware that there are restrictions on
|
||||
``max_length`` for some backends. Refer to the :doc:`database backend
|
||||
notes </ref/databases>` for details.
|
||||
|
||||
.. attribute:: CharField.db_collation
|
||||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
Optional. The database collation name of the field.
|
||||
|
||||
.. note::
|
||||
|
||||
Collation names are not standardized. As such, this will not be
|
||||
portable across multiple database backends.
|
||||
|
||||
.. admonition:: Oracle
|
||||
|
||||
Oracle supports collations only when the ``MAX_STRING_SIZE`` database
|
||||
initialization parameter is set to ``EXTENDED``.
|
||||
|
||||
``DateField``
|
||||
-------------
|
||||
|
@ -1329,6 +1345,21 @@ If you specify a ``max_length`` attribute, it will be reflected in the
|
|||
However it is not enforced at the model or database level. Use a
|
||||
:class:`CharField` for that.
|
||||
|
||||
.. attribute:: TextField.db_collation
|
||||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
The database collation name of the field.
|
||||
|
||||
.. note::
|
||||
|
||||
Collation names are not standardized. As such, this will not be
|
||||
portable across multiple database backends.
|
||||
|
||||
.. admonition:: Oracle
|
||||
|
||||
Oracle does not support collations for a ``TextField``.
|
||||
|
||||
``TimeField``
|
||||
-------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue