Replies: 1 comment
-
I'm new to Django Ninja and adopting after seeing DRF refuses to support async. I got excited about ModelController thinking it got us pretty close to what I'm used to with DRF it seems like an incomplete solution. Similarly, you can only look up records by pk, there's no way to use any other field or type it differently. There's an issue for this that's been open for a year. There's another package called django-ninja-crud but the docs are very sparse and it doesn't look like that much less work than writing your endpoints yourself. Personally I guess I'm going to fall back to generating schemas from models and writing my endpoints by hand I guess. Hopefully ModelControllers get a little more love in the near future because needing to write all endpoints by hand is a big step back from DRF and in their current state they're so close to being a good replacement. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
My understanding is that I should create a ModelService to support a ModelController in fulfilling requests. This is understandable and easy, but I can't figure out how to get to the user object, or request, or controller, from the ModelService. There is discussion about RouterContext, but that is also not available in the ModelService.
If I create the endpoint in the controller then I can do it, but it seems like the architecture encourages me to implement the CRUD in the ModelService, which means I need to filter there (unless I am out to lunch)
My use case is to limit the queryset to instances that belong to the user, for example.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions