1

In my application , I need to display the REST url(s) without a slash at the end. I have tried below combination but it didnt work.

Added APPEND_SLASH=True in the settings.py

and on the urls.py file

from rest_framework.routers import SimpleRouter
router = SimpleRouter(trailing_slash=False)

After adding this when I am calling the urls without slash at the end in the postman, it is giving me an 404 error- URL not found. But with slash at the end is working fine.

Is there any option to make this url without with slash at the end ? Especially for the post urls

Anish
  • 4,262
  • 6
  • 36
  • 58

1 Answers1

2

APPEND_SLASH will append it to the request (e.g. mysite/blog --> mysite/blog/). This is not what you want, since your urlconf explicitly says there should be no slash.

Also APPEND_SLASH is True by default. So you need to set it to False instead. That way, if you make a request without a slash, Django won't automatically add in a slash.

gatlanticus
  • 1,158
  • 2
  • 14
  • 28