How can I make a trailing slash optional on a Django Rest Framework SimpleRouter -


the docs can set trailing_slash=false how can allow both endpoints work, or without trailing slash?

you can override __init__ method of simplerouter class:

from rest_framework.routers import simplerouter   class optionalslashrouter(simplerouter):      def __init__(self):         self.trailing_slash = '/?'         super(simplerouter, self).__init__() 

the ? character make slash optional available routes.


Comments

Popular posts from this blog

minify - Minimizing css files -

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -