Reference¶
Utils¶
-
django_pgschemas.utils.
get_tenant_model
(require_ready: bool = True) → Optional[django.db.models.base.Model]¶ Returns the tenant model.
-
django_pgschemas.utils.
get_domain_model
(require_ready: bool = True) → Optional[django.db.models.base.Model]¶ Returns the domain model.
-
django_pgschemas.utils.
is_valid_identifier
(identifier: str) → bool¶ Checks the validity of identifier.
-
django_pgschemas.utils.
is_valid_schema_name
(name: str) → bool¶ Checks the validity of a schema name.
-
django_pgschemas.utils.
check_schema_name
(name: str)¶ Checks schema name and raises
ValidationError
ifname
is not a valid identifier.
-
django_pgschemas.utils.
remove_www
(hostname: str) → str¶ Removes
www
. from the beginning of the address. Only for routing purposes.www.test.com/login/
andtest.com/login/
should find the same tenant.
-
django_pgschemas.utils.
run_in_public_schema
(func)¶ Decorator that makes decorated function to be run in the public schema.
-
django_pgschemas.utils.
schema_exists
(schema_name: str) → bool¶ Checks if a schema exists in database.
-
django_pgschemas.utils.
create_or_clone_schema
(schema_name: str, sync_schema: bool = True, verbosity: int = 1) → bool¶ Creates the schema
schema_name
. Optionally checks if the schema already exists before creating it. ReturnsTrue
if the schema was created,False
otherwise.
Signals¶
-
django_pgschemas.signals.
schema_activate
= <django.dispatch.dispatcher.Signal object>¶ Sent after a schema has been activated
-
django_pgschemas.signals.
dynamic_tenant_needs_sync
= <django.dispatch.dispatcher.Signal object>¶ Sent when a schema from a dynamic tenant needs to be synced
-
django_pgschemas.signals.
dynamic_tenant_post_sync
= <django.dispatch.dispatcher.Signal object>¶ Sent after a tenant has been saved, its schema created and synced
-
django_pgschemas.signals.
dynamic_tenant_pre_drop
= <django.dispatch.dispatcher.Signal object>¶ Sent when a schema from a dynamic tenant is about to be dropped