make trailing slashes optional in API

This commit is contained in:
Tao Bojlen 2018-08-27 12:56:09 +02:00
parent 97a6d1321b
commit f7a8c1fe57

View file

@ -17,7 +17,15 @@ from django.urls import path, include
from rest_framework import routers
from apiv1 import views
router = routers.DefaultRouter()
class OptionalTrailingSlashRouter(routers.DefaultRouter):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.trailing_slash = r'/?'
router = OptionalTrailingSlashRouter()
router.register(r'instances', views.InstanceViewSet)
urlpatterns = [