I get a 404 error if slug begins with “id-”

I think there’s an issue here, but I’m not exactly sure what…

Clean project, enable LocaleMiddleware:

from django.conf.urls.i18n import i18n_patterns
from django.urls import path
from django.http import HttpResponse


def hello(request):
    return HttpResponse("hello")


urlpatterns = i18n_patterns(
    path("", hello),
    prefix_default_language=True,
)

/en/ 200.
/en-gb/ 200
/en-us/ 404

Using the URLconf defined in ticket_31540.urls, Django tried these URL patterns, in this order:
    en/
The current path, en-us/, didn't match any of these.

So this is because en-us isn’t a configured language but when determining the language we fellback to en correctly I guess, but then we didn’t resolve the URL using the same, or redirect to the fallback language URL.

It seems like that’s something we should do, or… ?

https://code.djangoproject.com/ticket/31540

1 Like