Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Entity type plugins

Type | `betty.model.Entity`
Repository | `betty.model.ENTITY_TYPE_REPOSITORY`

Entity types form the core of a Betty project’s ancestry. Each entity type describes a specific type of information, such as people or places. Ancestries can be filled with an unlimited number of entities (instances of entity types), that together describe a family’s history.

## Creating an entity type

1. Create a new class that extends `betty.model.Entity` and implements the abstract methods, for example:

       from typing import override
       from betty.model import Entity

       class MyEntity(Entity):
         @override
         @classmethod
         def plugin_id(cls) -> str:
             return "my-module-my-entity"

         # Implement remaining abstract methods...
         ...

2. Tell Betty about your entity type by registering it as an entry point. Given the entity type above in a module `my_package.my_module`, add the following to your Python package:

pyproject.toml

    [project.entry-points.'betty.entity_type']
    'my-module-my-entity' = 'my_package.my_module.MyEntity'

setup.py

    SETUP = {
        'entry_points': {
            'betty.entity_type': [
                'my-module-my-entity=my_package.my_module.MyEntity',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)

## See also

Read more about how to use entities and Betty’s built-in entity types at Ancestry.