mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-25 23:50:01 +03:00
Revert "replace try/except with context managger"
This reverts commit b95b6f0cbb
.
This commit is contained in:
parent
51602ce7e0
commit
3ed8554e3f
|
@ -16,8 +16,6 @@ automatically.
|
|||
router.register(r'users', UserViewSet, 'user')
|
||||
urlpatterns = router.urls
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
from collections import OrderedDict
|
||||
from functools import update_wrapper
|
||||
from inspect import getmembers
|
||||
|
@ -198,7 +196,7 @@ class ViewSetMixin:
|
|||
]
|
||||
|
||||
for action in actions:
|
||||
with contextlib.suppress(NoReverseMatch):
|
||||
try:
|
||||
url_name = '%s-%s' % (self.basename, action.url_name)
|
||||
namespace = self.request.resolver_match.namespace
|
||||
if namespace:
|
||||
|
@ -207,6 +205,9 @@ class ViewSetMixin:
|
|||
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:
|
||||
pass # URL requires additional arguments, ignore
|
||||
|
||||
return action_urls
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user