Make parameters order stable for multi-parameter URLs (#106)

Fixes #105

* Added intermittently failing test for #105
* Make parameter order stable for urls with multiple params
This commit is contained in:
John Carter
2018-04-24 04:16:22 +12:00
committed by Cristi Vîjdea
parent 6dd8ded05d
commit 322971f3e7
5 changed files with 41 additions and 1 deletions
+6
View File
@@ -1,3 +1,4 @@
from django.conf.urls import url
from rest_framework import routers
from todo import views
@@ -8,3 +9,8 @@ router.register(r'another', views.TodoAnotherViewSet)
router.register(r'yetanother', views.TodoYetAnotherViewSet)
urlpatterns = router.urls
urlpatterns += [
url(r'^(?P<todo_id>\d+)/yetanother/(?P<yetanother_id>\d+)/$',
views.NestedTodoView.as_view(),),
]
+5
View File
@@ -1,4 +1,5 @@
from rest_framework import viewsets
from rest_framework.generics import RetrieveAPIView
from .models import Todo, TodoAnother, TodoYetAnother
from .serializer import TodoAnotherSerializer, TodoSerializer, TodoYetAnotherSerializer
@@ -20,3 +21,7 @@ class TodoAnotherViewSet(viewsets.ReadOnlyModelViewSet):
class TodoYetAnotherViewSet(viewsets.ReadOnlyModelViewSet):
queryset = TodoYetAnother.objects.all()
serializer_class = TodoYetAnotherSerializer
class NestedTodoView(RetrieveAPIView):
serializer_class = TodoYetAnotherSerializer