Skip to content

base

django_spire.contrib.seeding.field.base

BaseFieldSeeder

Bases: ABC

Source code in django_spire/contrib/seeding/field/base.py
def __init__(
        self,
        fields: dict = None,
        default_to: str = "llm"
):

    self.fields = self._normalize_fields(fields or {})
    self.default_to = default_to

keyword = None class-attribute instance-attribute

seed_keywords = FieldSeederTypesEnum._value2member_map_.keys() class-attribute instance-attribute

fields = self._normalize_fields(fields or {}) instance-attribute

default_to = default_to instance-attribute

seeder_fields property

__init_subclass__

Source code in django_spire/contrib/seeding/field/base.py
def __init_subclass__(cls, **kwargs):
    super().__init_subclass__(**kwargs)

    if cls.keyword is None:
        message = 'Seeds must have a keyword'
        raise ValueError(message)

filter_fields

Source code in django_spire/contrib/seeding/field/base.py
def filter_fields(self, seed_type: str) -> dict:
    return {
        k: v for k, v in self.fields.items()
        if isinstance(v, tuple) and v[0] == seed_type
    }

seed abstractmethod

Source code in django_spire/contrib/seeding/field/base.py
@abstractmethod
def seed(self, model_seeder_cls, count: int):
    pass