eadwinCode/django-ninja-extra

"All controller endpoint must be `async`." Possible to make ModelControllerBase async?

Closed this issue · 2 comments

I'm trying to take full advantage of djano-ninja's async support. However when I apply AsyncJWTAuth() to a ModelControllerBase I get the error:

Exception: You are using a Controller level Asynchronous Authentication Class, All controller endpoint must be `async`.
Controller=MaterialController, endpoint=create_item_ebca41

I don't see anything about this in the docs. Is the ModelControllerBase abstraction only usable when not using async?

Thanks!

from ninja_extra import ModelConfig, ModelControllerBase, ModelSchemaConfig, api_controller, route

from materials.models import Material
from ninja_jwt.authentication import AsyncJWTAuth


@api_controller("/materials", auth=AsyncJWTAuth())
class MaterialController(ModelControllerBase):
    model_config = ModelConfig(
        model=Material,
        schema_config=ModelSchemaConfig(
            read_only_fields=[
                "id",
            ],
        ),
    )

@evanheckert ModelController at the moment supports only synchronous functions. I am currently looking into an async solution. But for now, ModelController can only work with synchronous Auth functions

Feature is live @evanheckert