6👍
You must give a unique name for the Named capturing group.
url(r'^video/(?P<pk1>[0-9]+)/quiz/(?P<pk2>[0-9]+)/list/$',
views.QuizList.as_view(),
name='quizzes-list'),
Access the corresponding pk*
values in the view through,
pk1 = kwargs.get('pk1', None)
pk2 = kwargs.get('pk2', None)
ex:
# quiz
class QuizList(generics.ListCreateAPIView):
queryset = Quizzes.objects.all()
serializer_class = QuizSerializer
def get(self, *args, **kwargs):
pk1 = kwargs.get('pk1', None)
pk2 = kwargs.get('pk2', None)
print pk1
print pk2
return super(QuizList, self).get(*args, **kwargs)
Source:stackexchange.com