Open hiaselhans opened 2 years ago
When using nested models, i try to optimize queries by using prefetch_related and select_related beforehand. Using ModelSchema, we could inspect the model and schema and optimize queries in the ModelSchema metaclass.
ModelSchema would require attributes like:
class ModelSchema(Schema, metaclass=ModelSchemaMetaclass): _prefetch_related: List[Prefetch | str] | None _select_related: List[str] | None
Do you think such functionality could make it into django-ninja? If so, I'd be happy to invest some time...
Did you end up implementing something like this?
When using nested models, i try to optimize queries by using prefetch_related and select_related beforehand. Using ModelSchema, we could inspect the model and schema and optimize queries in the ModelSchema metaclass.
ModelSchema would require attributes like:
Do you think such functionality could make it into django-ninja? If so, I'd be happy to invest some time...