mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
[soc2009/multidb] Renaming of database attributes - you now use NAME, ENGINE, etc rather than DATABASE_NAME, DATABASE_ENGINE inside DATABASES. Also deprecates the use of short names (.e.g., `sqlite3` for backends in ENGINE). Patch from Russell Keith-Magee.
Conflicts: docs/releases/1.2.txt git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11775 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -290,13 +290,13 @@ 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``. The simplest way to handle this in a ``db_type()`` method is to
|
||||
check the ``connection.settings_dict['DATABASE_ENGINE']`` attribute.
|
||||
check the ``connection.settings_dict['ENGINE']`` attribute.
|
||||
|
||||
For example::
|
||||
|
||||
class MyDateField(models.Field):
|
||||
def db_type(self, connection):
|
||||
if connection.settings_dict['DATABASE_ENGINE'] == 'mysql':
|
||||
if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
|
||||
return 'datetime'
|
||||
else:
|
||||
return 'timestamp'
|
||||
|
||||
Reference in New Issue
Block a user