django-ninja-extra icon indicating copy to clipboard operation
django-ninja-extra copied to clipboard

Mixins

Open mnboos opened this issue 6 months ago • 2 comments

Hi @eadwinCode

In order to create a company-internal solution for #271, I created API mixins (similar to those from DRF), that can be used to quickly create standard CRUD APIs like this:

# retrieve only
@api_controller("klienten", tags=["Klient"])
class KlientController(MixinModelControllerBase, RetrieveModelMixin, ListModelMixin):
    model_class = Klient

# all CRUD operations, manual schemas
@api_controller("eingliederungsfachpersonen", tags=["Eingliederungsfachperson"])
class EingliederungsfachpersonController(MixinModelControllerBase, CRUDModelMixin):
    model_class = Eingliederungsfachperson
    output_schema = EingliederungsfachpersonSchemaOutput
    input_schema = EingliederungsfachpersonSchemaInput

It also supports choice-models.

Would you be interested in a PR? If not, no problem and no bad feelings. 😁

mnboos avatar Jun 18 '25 08:06 mnboos