Skip to content

callable_seed

django_spire.contrib.seeding.field.seed.callable_seed

CallableFieldSeed

Bases: BaseFieldSeed

Source code in django_spire/contrib/seeding/field/seed/callable_seed.py
def __init__(self, callable_: Callable, wrapper: Callable | None = None, **kwargs) -> None:
    self.callable = callable_
    self.wrapper = wrapper
    self.kwargs = kwargs

callable = callable_ instance-attribute

wrapper = wrapper instance-attribute

kwargs = kwargs instance-attribute

generate_value

Source code in django_spire/contrib/seeding/field/seed/callable_seed.py
def generate_value(self, seed_index: int) -> Any:
    _ = seed_index

    if self.wrapper:
        return self.wrapper(self.callable(**self.kwargs))

    return self.callable(**self.kwargs)