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
Post a Comment