New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path parameters, order matters #1123
Comments
You can do @api.get("/stores/{int:store_id}")
def get_store(request, store_id: int):
print(f"Store {store_id}") Ninja will take path params the same way Django url routing normally does. This should fix this problem. This definitely needs to be documented better, it's sort of documented here but it's not clear that this is the solution to this problem. |
Wow, somehow I completely missed that part in the docs. And the worst part is that I tried doing the reverse thing, Although, this wouldn't work for things other that ints and uuids, right? For example ULIDs, UUIDs without the dashes, etc. |
You might be able to try registering your own custom path converters https://docs.djangoproject.com/en/5.0/topics/http/urls/#registering-custom-path-converters Since I think Ninja is just using Django's own path resolving this should work |
Is there a way to add something like this in the docs?
One of my team mates was faced with this problem and couldn't understand why when making a request to
/stores/verticals
the request was instead being processed by/stores/{store_id}
(and returning a 422 error becausestore_id
should be anint
)MRE:
The text was updated successfully, but these errors were encountered: