Optional tailing slash with Django
Fanciful Moment
The default urls of Django must include a tailing slash, otherwise, the framework will not recognize the url. But according to the user’s preference, the tailing slash will not be given most of the time. Here is the solution to change this rule. We can use the regex to match the tailing slash whatever it exists or not.
With rest_framework router
1 |
|
With django path
1 |
|
Refrences:
[1] https://stackoverflow.com/questions/59115733/how-to-make-trailing-slash-optional-in-django
Optional tailing slash with Django
https://r-future.github.io/post/optional-tailing-slash-with-django/