mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Fix viewsets action urls with namespaces (#7287)
Use the current request's namespace to resolve action urls.
This commit is contained in:
parent
3eef5f47f3
commit
bda84372d4
|
@ -150,6 +150,11 @@ class ViewSetMixin:
|
|||
Reverse the action for the given `url_name`.
|
||||
"""
|
||||
url_name = '%s-%s' % (self.basename, url_name)
|
||||
namespace = None
|
||||
if self.request and self.request.resolver_match:
|
||||
namespace = self.request.resolver_match.namespace
|
||||
if namespace:
|
||||
url_name = namespace + ':' + url_name
|
||||
kwargs.setdefault('request', self.request)
|
||||
|
||||
return reverse(url_name, *args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user