Issue
I have a view and action defined in it:
class V(mixins.UpdateModelMixin, GenericViewSet):
`` some codes``
lookup_field = 'uuid'
@action(detail=True, methods=['put'], permission_classes=[IsAdminUser], url_path='approve/(?P<uuid>[\w-]+)')
def approve(self, request, *args, **kwargs):
obj = self.get_object()
`` some codes ``
The app doesn't run because of:
django.core.exceptions.ImproperlyConfigured: "^url/(?P[^/.]+)/approve/(?P[\w-]+)/$" is not a valid regular expression: redefinition of group name 'uuid' as group 2; was group 1 at position 46
urls.py in the app directory:
router = routers.DefaultRouter()
router.register(r'url', views.V, basename='url')
The correct configuration would be like ^url/approve/(?P<uuid>[\w-]+)/$
, but as the error says, it's another pattern and I don't mean it. Any idea would be appreciated
Solution
Thr problem solved by just adding parameter uuid
as an argument to the method.
def approve(self, request, uuid, *args, **kwargs):
`blah blah blah`
Answered By - Zahra Ashouri
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.