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[str, Any],
    field_names: list[str],
    default_to: str,
    model_class: Any
) -> None:
    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 in ("exclude", ("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()

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