mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[soc2009/multidb] Added a using option to a Model's Meta class. This allows you to select the default database for a specific model, in addition to the global default
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11135 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -103,7 +103,7 @@ model handling are exactly the same as normal. This includes
|
||||
unmanaged model, then the intermediate table for the many-to-many join
|
||||
will also not be created. However, a the intermediary table between one
|
||||
managed and one unmanaged model *will* be created.
|
||||
|
||||
|
||||
If you need to change this default behavior, create the intermediary
|
||||
table as an explicit model (with ``managed`` set as needed) and use the
|
||||
:attr:`ManyToManyField.through` attribute to make the relation use your
|
||||
@@ -210,6 +210,17 @@ set of fields::
|
||||
|
||||
unique_together = ("driver", "restaurant")
|
||||
|
||||
``using``
|
||||
---------
|
||||
|
||||
.. attribute:: Options.using
|
||||
|
||||
The alias for the default database to be used for this model. If this is not
|
||||
provided the default is ``'default'``. If it is porvided it can be overidden
|
||||
at the ``QuerySet`` level with the ``using()`` method.
|
||||
|
||||
.. versionadded:: TODO
|
||||
|
||||
``verbose_name``
|
||||
----------------
|
||||
|
||||
@@ -232,4 +243,3 @@ The plural name for the object::
|
||||
verbose_name_plural = "stories"
|
||||
|
||||
If this isn't given, Django will use :attr:`~Options.verbose_name` + ``"s"``.
|
||||
|
||||
|
||||
@@ -25,6 +25,15 @@ thing to note is that your primary database should have the alias
|
||||
``'default'``, and any additional databases you have can have whatever alias
|
||||
you choose.
|
||||
|
||||
Selecting a Database for a ``Model``
|
||||
====================================
|
||||
|
||||
In addition to the global default database for all models, it is possible to
|
||||
select a default database on a per-model level. This is done using the
|
||||
``using`` option in a model's inner ``Meta`` class. When provided this
|
||||
database becomes the default database for all lookups, saves, and deletes for
|
||||
this model. It can be overiden on a per-query basis as described below.
|
||||
|
||||
Selecting a Database for a ``QuerySet``
|
||||
=======================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user