isolate_apps
Act as either a decorator or a context manager to register models defined in its wrapped context to an isolated registry.
Attributes
| Attribute | Type | Description |
|---|---|---|
| installed_apps | tuple | A collection of app labels that the isolated registry should contain when the context is enabled. |
| old_apps | django.apps.registry.Apps | Stores the original global application registry to allow restoration of the default state when the context is disabled. |
| attr_name | string | Attribute assigned the isolated registry if used as a class decorator. |
| kwarg_name | string | Keyword argument passing the isolated registry if used as a function decorator. |
Constructor
Signature
def isolate_apps(
*installed_apps: tuple,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *installed_apps | tuple | A variable list of app labels that the isolated registry should contain. |
| **kwargs | dict | Keyword arguments including 'attr_name' for class decoration or 'kwarg_name' for function decoration. |
Signature
def isolate_apps(
*installed_apps: str,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *installed_apps | str | A variable list of app labels that the isolated registry should contain. |
| **kwargs | dict | Keyword arguments including 'attr_name' for class decoration or 'kwarg_name' for function decoration. |
Methods
enable()
@classmethod
def enable() - > [Apps](../../../apps/registry/apps.md?sid=django_apps_registry_apps)
Swaps the global default apps registry with a new isolated registry containing only the specified installed apps.
Returns
| Type | Description |
|---|---|
[Apps](../../../apps/registry/apps.md?sid=django_apps_registry_apps) | The newly created isolated Apps registry instance. |
disable()
@classmethod
def disable() - > null
Restores the original global apps registry that was in place before the isolated context was enabled.
Returns
| Type | Description |
|---|---|
null | None |