summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-08-24 16:16:44 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-08-24 16:17:13 +0200
commitd95a0144e532f6ad30c0840b723f6d3928e6d1ad (patch)
treebae1c577ffeca286112af6f736774fb4147a9b99
parent358e65a5cdd8430b50a1e3e7346b212a914ad41e (diff)
downloaddjango-d95a0144e532f6ad30c0840b723f6d3928e6d1ad.tar.gz
[3.2.x] Used backend vendors in custom model fields docs.
Backport of d7394cfa13a4d1a02356e3a83e10ec100fbb9948 from main
-rw-r--r--docs/howto/custom-model-fields.txt5
1 files changed, 3 insertions, 2 deletions
diff --git a/docs/howto/custom-model-fields.txt b/docs/howto/custom-model-fields.txt
index 2572b2ed39..d3692f0325 100644
--- a/docs/howto/custom-model-fields.txt
+++ b/docs/howto/custom-model-fields.txt
@@ -394,13 +394,14 @@ If you aim to build a database-agnostic application, you should account for
differences in database column types. For example, the date/time column type
in PostgreSQL is called ``timestamp``, while the same column in MySQL is called
``datetime``. You can handle this in a :meth:`~Field.db_type` method by
-checking the ``connection.settings_dict['ENGINE']`` attribute.
+checking the ``connection.vendor`` attribute. Current built-in vendor names
+are: ``sqlite``, ``postgresql``, ``mysql``, and ``oracle``.
For example::
class MyDateField(models.Field):
def db_type(self, connection):
- if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
+ if connection.vendor == 'mysql':
return 'datetime'
else:
return 'timestamp'