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
This commit is contained in:
gabn88 2022-08-31 12:17:19 +02:00 committed by GitHub
parent c7acdd6006
commit 54d52c66fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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