Skip to main content

isolate_apps

Act as either a decorator or a context manager to register models defined in its wrapped context to an isolated registry.

Attributes

AttributeTypeDescription
installed_appstupleA collection of app labels that the isolated registry should contain when the context is enabled.
old_appsdjango.apps.registry.AppsStores the original global application registry to allow restoration of the default state when the context is disabled.
attr_namestringAttribute assigned the isolated registry if used as a class decorator.
kwarg_namestringKeyword argument passing the isolated registry if used as a function decorator.

Constructor

Signature

def isolate_apps(
*installed_apps: tuple,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
*installed_appstupleA variable list of app labels that the isolated registry should contain.
**kwargsdictKeyword arguments including 'attr_name' for class decoration or 'kwarg_name' for function decoration.

Signature

def isolate_apps(
*installed_apps: str,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
*installed_appsstrA variable list of app labels that the isolated registry should contain.
**kwargsdictKeyword 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

TypeDescription
[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

TypeDescription
nullNone