Refs #31777 -- Doc'd Char/TextField.db_collation parameter in MySQL notes.

This commit is contained in:
Mariusz Felisiak 2020-10-02 13:29:50 +02:00 committed by GitHub
parent 06c5d3fafc
commit 292b3be698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -398,11 +398,15 @@ Collation settings
~~~~~~~~~~~~~~~~~~
The collation setting for a column controls the order in which data is sorted
as well as what strings compare as equal. It can be set on a database-wide
level and also per-table and per-column. This is `documented thoroughly`_ in
the MySQL documentation. In all cases, you set the collation by directly
manipulating the database tables; Django doesn't provide a way to set this on
the model definition.
as well as what strings compare as equal. You can specify the ``db_collation``
parameter to set the collation name of the column for
:attr:`CharField <django.db.models.CharField.db_collation>` and
:attr:`TextField <django.db.models.TextField.db_collation>`.
The collation can also be set on a database-wide level and per-table. This is
`documented thoroughly`_ in the MySQL documentation. In such cases, you must
set the collation by directly manipulating the database settings or tables.
Django doesn't provide an API to change them.
.. _documented thoroughly: https://dev.mysql.com/doc/refman/en/charset.html
@ -432,6 +436,10 @@ because it is more accurate.
differ only by case will pass validation, but upon calling ``save()``, an
``IntegrityError`` will be raised.
.. versionchanged:: 3.2
Support for setting a database collation for the field was added.
Connecting to the database
--------------------------