djangodjango-rest-frameworkdjango-viewsdrf-yasg

Django Action Append Slash


I am making development, and my POST request come like config/alert and I am trying to catch it with action decorater below.BUT Django does not catch it It wants config/alert/ but It is not possible to change incoming url add the SLASH.

@action(methods=['post'], detail=False, url_path='alert')
def get_post(self, request, pk=None, *args, **kwargs):

How can I modify the action to listen without slash in POST request?


Solution

  • I found the solution adding extra APIView and putting ? end of the re_path in urls.py

    re_path(r'alerta_forward/alert/?', post_data)
    

    With using ? it became option slash, then I called an APIView.