I have a quite complex application, which was working fine with Django 5.2.9 and does not work with django 6.0.
When I use the command runserver and I access any page I get:
A server error occurred. Please contact the administrator.
My main urls.py after removing everything else for testing purposes is:
from django.urls import include, path
from django.utils.translation import gettext_lazy
urlpatterns = [
path(gettext_lazy('invitation/'), include('invitation.urls')),
]
and the invitation.urls is:
from django.urls import path
from django.utils.translation import gettext_lazy
from django.views.generic import TemplateView
urlpatterns = [
path(gettext_lazy('request/'), TemplateView.as_view(template_name='invitation/request.html'), name='invitation.request'),
]
If I remove gettext_laxy from path(gettext_lazy('invitation/'), include('invitation.urls')) (but leaving it in invitation.urls) the error disappears.
If I remove it from invitation.urls but leave it in urls.py the error remains.
Something like the following in urls.py works just fine:
path(gettext_lazy('about/'), TemplateView.as_view(template_name='about.html'), name='about'),
The error I get in the console is the following:
Traceback (most recent call last):
File "/home/andrea/virtualenv/entertainment/lib/python3.13/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/andrea/virtualenv/entertainment/lib/python3.13/site-packages/django/core/handlers/base.py", line 182, in _get_response
callback, callback_args, callback_kwargs = self.resolve_request(request)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/home/andrea/virtualenv/entertainment/lib/python3.13/site-packages/django/core/handlers/base.py", line 314, in resolve_request
resolver_match = resolver.resolve(request.path_info)
File "/home/andrea/virtualenv/entertainment/lib/python3.13/site-packages/django/urls/resolvers.py", line 678, in resolve
sub_match = pattern.resolve(new_path)
File "/home/andrea/virtualenv/entertainment/lib/python3.13/site-packages/django/urls/resolvers.py", line 673, in resolve
match = self.pattern.match(path)
File "/home/andrea/virtualenv/entertainment/lib/python3.13/site-packages/django/urls/resolvers.py", line 344, in match
elif path.startswith(self._route):
~~~~~~~~~~~~~~~^^^^^^^^^^^^^
TypeError: startswith first arg must be str or a tuple of str, not __proxy__
During handling of the above exception, another exception occurred:
(at this point the message above is repeated in an infinite loop).
It might be related to this commit:
amending it with:
elif path.startswith(str(self._route)):
return path.removeprefix(str(self._route)), (), {}
fixes the issue.
Ticket: