Skip to content

Manager class

edgy.Manager

Manager(model_class=None)

Base Manager for the Edgy Models. To create a custom manager, the best approach is to inherit from the ModelManager.

Example

from saffier.managers import ModelManager
from saffier.models import Model


class MyCustomManager(ModelManager):
    ...


class MyOtherManager(ModelManager):
    ...


class MyModel(saffier.Model):
    query = MyCustomManager()
    active = MyOtherManager()

    ...
PARAMETER DESCRIPTION
model_class

TYPE: Any DEFAULT: None

Source code in edgy/core/db/models/managers.py
38
39
def __init__(self, model_class: Any = None):
    self.model_class = model_class

model_class instance-attribute

model_class = model_class

__get__

__get__(_, owner)
PARAMETER DESCRIPTION
_

TYPE: Any

owner

TYPE: Any

Source code in edgy/core/db/models/managers.py
41
42
def __get__(self, _: Any, owner: Any) -> Type["QuerySet"]:
    return cast("Type[QuerySet]", self.__class__(model_class=owner))

get_queryset

get_queryset()

Returns the queryset object.

Checks for a global possible tenant and returns the corresponding queryset.

Source code in edgy/core/db/models/managers.py
44
45
46
47
48
49
50
51
52
53
54
55
56
def get_queryset(self) -> "QuerySet":
    """
    Returns the queryset object.

    Checks for a global possible tenant and returns the corresponding queryset.
    """
    tenant = get_tenant()
    if tenant:
        set_tenant(None)
        return QuerySet(
            self.model_class, table=self.model_class.table_schema(tenant)  # type: ignore
        )
    return QuerySet(self.model_class)