does django-ninja intentionally not allow api routes like `/users/me` but require `/users/{user_id}`
See original GitHub issueTrying to do something like:
@router.get("/users/test", response=str)
def user_test(request):
return "hello"
Throws error:
{
"detail": [
{
"loc": [
"path",
"user_id"
],
"msg": "value is not a valid uuid",
"type": "type_error.uuid"
}
]
}
how to get around this?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Defining a Schema - Django Ninja
Imagine you need to create an API operation that creates a user. The input parameter would be username+password, but output of this operation...
Read more >Customizing permissions and responses for detail routes in ...
If a user is an admin they can use the 'post' method at the /api/v2/users url. If they are not authenticated they get...
Read more >4 - Authentication and permissions - Django REST framework
Currently our API doesn't have any restrictions on who can edit or delete code snippets. We'd like to have some more advanced behavior...
Read more >Setting up JWT Authentication - Thinkster.io
In Django, sessions are stored as cookies. These sessions, along with some built-in middleware and request objects, ensure that there is a user...
Read more >Starting With REST APIs and Django Ninja - YouTube
The Django Ninja library is a FastAPI-inspired tool kit for turning Django views into REST API endpoints with very little extra code.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@RiccardoCherchi it is the way django urls work if you know for sure that your user_id is uuid - you can help django url resolver to pin to correct path - just add
uuid:user_id
- it will passed to urlresolver:but in case your user ids are strings - the only thing that will help is placing /user/me BEFORE /user/user_id in codebase
Actually didn’t know this, Django surprise me every time, thanks for the clarification!!