mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #23528 -- Doc'd django.db.migrations.swappable_dependency().
This commit is contained in:
parent
27fed08e5f
commit
7d96ce68ae
@ -218,6 +218,26 @@ Apps without migrations must not have relations (``ForeignKey``,
|
|||||||
``ManyToManyField``, etc.) to apps with migrations. Sometimes it may work, but
|
``ManyToManyField``, etc.) to apps with migrations. Sometimes it may work, but
|
||||||
it's not supported.
|
it's not supported.
|
||||||
|
|
||||||
|
Swappable dependencies
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
.. function:: django.db.migrations.swappable_dependency(value)
|
||||||
|
|
||||||
|
The ``swappable_dependency()`` function is used in migrations to declare
|
||||||
|
"swappable" dependencies on migrations in the app of the swapped-in model.
|
||||||
|
Currently, the first migration of this app and as a consequence the swapped-in
|
||||||
|
model should be created in the initial migration. The argument ``value`` is a
|
||||||
|
string ``"<app label>.<model>"`` describing an app label and a model name, e.g.
|
||||||
|
``"myapp.MyModel"``.
|
||||||
|
|
||||||
|
By using ``swappable_dependency()``, you inform the migration framework that
|
||||||
|
the migration relies on a migration which sets up up a swappable model,
|
||||||
|
allowing for the possibility of substituting the model with a different
|
||||||
|
implementation in the future. This is typically used for referencing models
|
||||||
|
that are subject to customization or replacement, such as the custom user
|
||||||
|
model (``settings.AUTH_USER_MODEL``, which defaults to ``"auth.User"``) in
|
||||||
|
Django's authentication system.
|
||||||
|
|
||||||
.. _migration-files:
|
.. _migration-files:
|
||||||
|
|
||||||
Migration files
|
Migration files
|
||||||
|
Loading…
Reference in New Issue
Block a user