Hey,
Could you try with below code?

def handler500(request, *args, **kwargs):

On Mon, Nov 23, 2020, 10:48 PM Marc Streeter <mstree...@gmail.com> wrote:

> Using:
>  - django 3.1.3
>  - djangorestframework  3.12.2
>
> I've been trying to get `handler500` to work with `@api_view` decorator.
>
> ## Steps to reproduce
>
> provide the view like so
>
> populate file core/util/response.py
>
> ```
> from rest_framework.decorators import api_view
> from rest_framework.response import Response
>
> @api_view(["GET"])
> def handler500(request):
>     payload = {"message": "system error", "success": False, "data": None }
>     return Response(data=payload, status=500, exception=True)
> ```
> populate file app/urls.py
> ```
> handler500 = "core.util.response.handler500"
> ```
>
> and then starting Django with
>
> ```
> python manage.py runserver 0.0.0.0:8888
> ```
>
> ## Expected behavior
>
> starts Django successfully (with handler500 able to be used)
>
> ## Actual behavior
>
> Django crashes on start up with the following error
>
> ```
> ERRORS:
> ?: (urls.E007) The custom handler500 view
> 'core.util.response.WrappedAPIView' does not take the correct number of
> arguments (request).
>
> System check identified 1 issue (0 Silenced).
> ```
>
>
>
> ## Additional notes:
> I am able to use the above with `handler404` without issue (and it works
> as expected), for `handler500` I have to use `django.http.HttpResponse`
> instead.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-rest-framework+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-rest-framework/1a3c89fa-df02-41e9-a7f3-39fc7227516an%40googlegroups.com
> <https://groups.google.com/d/msgid/django-rest-framework/1a3c89fa-df02-41e9-a7f3-39fc7227516an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/CAMKMUjsDQMKvyAnSapad84GC8t3%3DJeLpOX9zG3z%2BLHD3j9jyQw%40mail.gmail.com.

Reply via email to