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

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -