Repository: encode/django-rest-framework

Issue:
Seems `Viewset`s `get_extra_action_url_map` method does not recognize namespaces
Seems `Viewset`s `get_extra_action_url_map` method does not recognize namespaces. I'm using different apps via Django URL namespaces ("<namespace>:<url name>") but the DRF action pull down menu will not provide it. My quick fix looks like:

```
    def get_extra_action_url_map(self):
        action_urls = OrderedDict()

        # exit early if `detail` has not been provided
        if self.detail is None:
            return action_urls

        # filter for the relevant extra actions
        actions = [
            action for action in self.get_extra_actions()
            if action.detail == self.detail
        ]
        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
            except NoReverseMatch as exc:
                pass  # URL requires additional arguments, ignore

        return action_urls
```

which basically add these two lines:

```
                namespace = self.request.resolver_match.namespace
                if namespace:
                    url_name = '%s:%s' % (namespace, url_name)
```
The fix works fine for me since years, but it seems that nobody else has been stumbled about it before.

Regards
Frank

_Originally posted by @backbohne in https://github.com/encode/django-rest-framework/discussions/7816_

Is there any specific reason why this fix is not merged? 


Discussion:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Tickets like this mostly get stuck because there's always associated risk that the change will break existing projects.

Personally I think that ViewSets and Routers are an overcomplicated abstraction that we introduced, and it's difficult to pick apart the impact of any changes around them.

If we *did* want to push forward with a change here, then the first step would be a pull request introducing this change, in order to determine if that breaks any existing tests. That'd at least give us *some* level of confidence in the change.

Resolving patch:
diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py
--- a/rest_framework/viewsets.py
+++ b/rest_framework/viewsets.py
@@ -198,6 +198,10 @@ def get_extra_action_url_map(self):
         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


Test patch: