diff options
| author | DevilsAutumn <bhuvnesh875@gmail.com> | 2023-05-16 15:29:01 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-06-02 20:57:41 +0200 |
| commit | 7d96ce68ae2c1bab1f2ab64ddc2b2c6004278af0 (patch) | |
| tree | 43d401432b7e552ed400e110458d4b9dd83e18be /docs | |
| parent | 27fed08e5ff597c813de25b6e89dc300a1f4231b (diff) | |
Fixed #23528 -- Doc'd django.db.migrations.swappable_dependency().
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/migrations.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/topics/migrations.txt b/docs/topics/migrations.txt index d069efb434..f2d2d915c1 100644 --- a/docs/topics/migrations.txt +++ b/docs/topics/migrations.txt @@ -218,6 +218,26 @@ Apps without migrations must not have relations (``ForeignKey``, ``ManyToManyField``, etc.) to apps with migrations. Sometimes it may work, but 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 |
