Opened 103 minutes ago
Closed 81 minutes ago
#36861 closed Bug (duplicate)
technical_404.html crashes on urlpatterns with include()
| Reported by: | Christian Bahls | Owned by: | |
|---|---|---|---|
| Component: | Error reporting | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Christian Bahls | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
technical_404.html crashes on urlpatterns with include()
Summary
The debug 404 page (technical_404.html) crashes with an AttributeError when urlpatterns contains URLResolver objects created via include().
Description
The template iterates over URL patterns and accesses .name:
{% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %}
This fails because .name only exists on URLPattern, not URLResolver. The {% if %} guard does not prevent the crash because Django's template engine evaluates pat.name before checking the conditional.
Exception
AttributeError: 'URLResolver' object has no attribute 'name'
Reproduce
- Configure urlpatterns with
include()without namespace:urlpatterns = [ path("app/", include("myapp.urls")), ]
- Set
DEBUG=True - Request any non-existent URL
- Debug 404 page crashes instead of rendering
Fix
Change History (2)
comment:1 by , 85 minutes ago
comment:2 by , 81 minutes ago
| Has patch: | unset |
|---|---|
| Resolution: | → duplicate |
| Status: | new → closed |
| UI/UX: | unset |
Duplicate of #26886, this behavior didn't change recently. Also, it doesn't crash, it just logs this noisy traceback.
i run django 6.0.1 from PyPI in a docker and it crashes
please consider a backport