schematools.contrib.django.factories module

schematools.contrib.django.factories.is_dangling_model(model: type[schematools.contrib.django.models.DynamicModel]) bool

Tell whether the model should have been removed, as everything reloaded.

schematools.contrib.django.factories.model_factory(dataset: Dataset, table_schema: DatasetTableSchema, base_app_name: str | None = None, base_model: type[M] = <class 'schematools.contrib.django.models.DynamicModel'>) type[M]

Generate a Django model class from a JSON Schema definition.

schematools.contrib.django.factories.model_mocker_factory(dataset: Dataset, table_schema: DatasetTableSchema, base_app_name: Optional[str] = None) Type[DynamicModelMocker]

Generate a Django model mocker class from a JSON Schema definition.

schematools.contrib.django.factories.remove_dynamic_models() None

Erase model caches for dynamically generated models. This completely removes the models from the Django app registry.

If your own code also holds references to models, these need to be removed separately. The is_dangling_model() function allows to check whether a model originated from a previous factory invocation.

schematools.contrib.django.factories.schema_model_mockers_factory(dataset: Dataset, tables: Optional[Collection[str]] = None, base_app_name: Optional[str] = None) List[Type[DynamicModelMocker]]

Generate Django model mockers from the data of the schema.

schematools.contrib.django.factories.schema_models_factory(dataset: Dataset, tables: Collection[str] | None = None, base_app_name: str | None = None, base_model: type[M] = <class 'schematools.contrib.django.models.DynamicModel'>) list[type[M]]

Generate Django models from the data of the schema.