Django's APPEND_SLASH setting does not work with static, why?

Viewed 34

Django's 4.1.1 APPEND_SLASH setting automatically appends a slash / until I add static roots, i.e. urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT).

For example, this works with http://127.0.0.1:8000/admin and http://127.0.0.1:8000/admin/

urlpatterns = [
    path('', home),
    path('admin/', admin.site.urls),
]

However, adding my static roots and the setting no longer takes effect:

urlpatterns = [
    path('', home),
    path('admin/', admin.site.urls),
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Why? Is this a bug? How is urlpatterns += static etc impacting Django's setting?

0 Answers
Related