Skip to content

seed

django_spire.knowledge.seeding.seed

parent_collection_seeder = CollectionSeeder(count=1) module-attribute

child_collection_seeder = ChildCollectionSeeder(count=4) module-attribute

grandchild_collection_seeder = GrandchildCollectionSeeder(count=3) module-attribute

entry_seeder = EntrySeeder(count=15) module-attribute

ChildCollectionSeeder

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.Collection class-attribute instance-attribute

fields_seeds = {'id': Seeder.exclude(), 'parent_id': Seeder.model.random_queryset_foreign_key(models.Collection.objects.parentless()), 'name': Seeder.llm(str, 'A name for a child knowledge base collection, e.g. a topic within a department.'), 'description': Seeder.llm(str, 'Short description of what documents this child knowledge base collection holds.')} class-attribute instance-attribute

__post_seed_database__

Source code in django_spire/knowledge/collection/seeding/seeder.py
def __post_seed_database__(self) -> None:
    CollectionSeeder._correct_order()

CollectionSeeder

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.Collection class-attribute instance-attribute

fields_seeds = {'id': Seeder.exclude(), 'parent_id': Seeder.exclude(), 'name': Seeder.llm(str, 'A name for a knowledge base collection, e.g. a department, team, or topic area.'), 'description': Seeder.llm(str, 'Short description of what documents this knowledge base collection holds.')} class-attribute instance-attribute

__post_seed_database__

Source code in django_spire/knowledge/collection/seeding/seeder.py
def __post_seed_database__(self) -> None:
    self._correct_order()

GrandchildCollectionSeeder

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.Collection class-attribute instance-attribute

fields_seeds = {'id': Seeder.exclude(), 'parent_id': Seeder.model.random_queryset_foreign_key(models.Collection.objects.filter(parent__isnull=False)), 'name': Seeder.llm(str, 'A name for a nested knowledge base collection, e.g. a sub-topic within a child.'), 'description': Seeder.llm(str, 'Short description of what documents this nested knowledge base collection holds.')} class-attribute instance-attribute

__post_seed_database__

Source code in django_spire/knowledge/collection/seeding/seeder.py
def __post_seed_database__(self) -> None:
    CollectionSeeder._correct_order()

EntrySeeder

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.Entry class-attribute instance-attribute

fields_seeds = {'id': Seeder.exclude(), 'current_version_id': Seeder.exclude(), 'collection_id': Seeder.model.random_foreign_key(Collection), 'name': Seeder.llm(str, 'A name for a document in a company knowledge base: a policy or process article.')} class-attribute instance-attribute

__post_seed_database__

Source code in django_spire/knowledge/entry/seeding/seeder.py
def __post_seed_database__(self) -> None:
    self._correct_order()
    self._set_current_version()

    for entry in self.queryset:
        entry.services.tag.process_and_set_tags()