Replies: 4 comments 2 replies
-
|
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.
-
gives you the request object inside the service methods. |
Beta Was this translation helpful? Give feedback.
-
|
@hairypalm Sorry for replying late to this Q&A. I have been very busy with work. @ryanovas ModelController is a complete solution but its still open for improvement. I also want you to know that the goal of Django-Ninja-Extra is help DRF devs transition into Django-Ninja seemlessly with less stress. So if there is something thats doesnt seem right, please create an issue and we can look into it. Also, can you share the issue that has been open for one year? I must have missed it |
Beta Was this translation helpful? Give feedback.
-
|
@eadwinCode It's been quite some time since I wrote that, so my memory is very hazy now. I think this is the issue I was referring to: #178 And the big blocker for me is that I was looking things up with slugs, not pk and sometimes pk is not an int (uuid, etc) and the current implementation is entirely inflexible to support that but in DRF I can just set lookup field. |
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