#32260: handler500 as a Class-based view raises SystemCheckError
-------------------------------------+-------------------------------------
Reporter: Daniyal Abbasi | Owner: Daniyal
| Abbasi
Type: Bug | Status: assigned
Component: Core (System | Version: 3.1
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Daniyal Abbasi):
* owner: nobody => Daniyal Abbasi
* status: new => assigned
Old description:
> Setting handler500 as a Class-Based view raises the following error which
> running checks.
>
> {{{
> $ python manage.py check
> SystemCheckError: System check identified some issues:
>
> ERRORS:
> ?: (urls.E007) The custom handler500 view 'path.to.my.MyView' does not
> take the correct number of arguments (request).
> }}}
>
> In my root urls.py, I have the following configuration,
>
> {{{
> handler404 = MyView.as_view()
> handler500 = MyView.as_view()
> }}}
New description:
Setting handler500 as a Class-Based view raises the following error which
running checks.
{{{
$ python manage.py check
SystemCheckError: System check identified some issues:
ERRORS:
?: (urls.E007) The custom handler500 view 'path.to.my.MyView' does not
take the correct number of arguments (request).
}}}
In my root urls.py, I have the following configuration,
{{{
handler404 = MyView.as_view()
handler500 = MyView.as_view()
}}}
I believe this is due to the function `_check_custom_error_handlers` in
`django/urls/resolver.py`. The signature variable in this function is
expected to match (request, exception) for all handlers except for
handler500 which is expected to have only (request). A positional
argument, template_name is also present.
While using class based views, we get two positional arguments (self,
request) and then it recieves *args and * *kwargs. The check is permitting
other handlers as the number of arguments coincidentally match.
I suggest a fix in the `_check_custom_error_handlers` which first checks
if the handler* are function based or class based, and then it preceed the
check with the appropriate number of arguments.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32260#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.edd43afda310c99c5d0b6d3166454328%40djangoproject.com.