Skip to content

seeder

django_spire.metric.visual.presentation.seeding.seeder

PresentationSeeder

Bases: Seeder

Source code in django_spire/contrib/seeding/seeder.py
def __init__(self, count: int = 1, verbose: bool = True) -> None:
    self.seeds: list[Seed] = []
    self._model_object_ids: list[int | str] = []
    self._count: int = count
    self.verbose: bool = verbose

model_class = models.Presentation class-attribute instance-attribute

fields_seeds = {'id': Seeder.exclude(), 'created_datetime': Seeder.fake.date_time_between(start_date='-30d', end_date='now'), 'name': Seeder.fake.sentence(), 'description': Seeder.fake.paragraph(2), 'is_active': Seeder.static(True), 'is_deleted': Seeder.static(False)} class-attribute instance-attribute

seed_database

Source code in django_spire/metric/visual/presentation/seeding/seeder.py
def seed_database(self, count: int | None = None) -> QuerySet:
    self.seed(count)

    model_objects = []

    for fields_values in self.to_list_of_dicts():
        presentation = models.Presentation.objects.create(**fields_values)
        self._seed_slides(presentation)
        model_objects.append(presentation)

    self._model_object_ids = [model_object.id for model_object in model_objects]

    return self.queryset