Skip to content

config

django_spire.contrib.seeding.model.django.config

DjangoModelFieldsConfig

Bases: FieldsConfig

Source code in django_spire/contrib/seeding/model/config.py
def __init__(
        self,
        raw_fields: dict,
        field_names: list[str],
        default_to: str,
        model_class
):
    self.raw_fields = raw_fields or {}
    self.default_to = default_to
    self.field_names = set(field_names)
    self.model_class = model_class

    self._excluded = {
        k for k, v in self.raw_fields.items()
        if v == "exclude" or v == ("exclude",)
    }

    self.fields = normalize_seeder_fields({
        k: v for k, v in self.raw_fields.items() if k not in self._excluded
    })

    self._validate()
    self._assign_defaults()
    self._order_fields() # Fields need to be in order for caching hash