From 54d52c66fd221e9ff86d8b428c6c0178c0501606 Mon Sep 17 00:00:00 2001 From: gabn88 Date: Wed, 31 Aug 2022 12:17:19 +0200 Subject: [PATCH] Fixes that namespaced views now also appear in the extra actions (#8598) * Fixes that namespaced views now also appear in the extra actions Before this fix, namespaced views would not appear in the extra actions. With this fix they do. * Flake fix --- rest_framework/viewsets.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index 5a1f8acf5..1c56f61e8 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -198,6 +198,10 @@ class ViewSetMixin: for action in actions: try: url_name = '%s-%s' % (self.basename, action.url_name) + namespace = self.request.resolver_match.namespace + if namespace: + url_name = '%s:%s' % (namespace, url_name) + url = reverse(url_name, self.args, self.kwargs, request=self.request) view = self.__class__(**action.kwargs) action_urls[view.get_view_name()] = url