module strapi_client.model_utils
function get_model_fields_and_population
get_model_fields_and_population(
model_class: type[BaseModel]
) → tuple[list[str], dict[str, Any]]
Recursively scans class fields and returns fields and populate structure for Strapi API. Uses pydantic aliases when available, otherwise field names.
Returns:
tuple[list[str], Dict[str, Any]]
: (fields_list, populate_dict)
fields_list: Contains scalar field names for the root model populate_dict: Contains nested structure with relations and their fields
Example result: fields = ['title', 'slug'] populate = {
- 'headerImage'
: {
- 'fields'
: ['name', 'url'] },
- 'category'
: {
- 'fields'
: ['name'],
- 'populate'
: {
- 'icon'
: {
- 'fields'
: ['url', 'name'] } } } }
This file was automatically generated via lazydocs.