dimanche 20 août 2017

Django: Is APPEND_SLASH set to True even if not in settings.py?

Here is my urls.py:

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

If I type 127.0.0.1:8000/polls in my browser (Firefox) I get redirected to 127.0.0.1:8000/polls/ (with slash at the end).

To be honest, I am confused why that is. Because in my settings.pythere is no

APPEND_SLASH = True

However, the Django docs say:

APPEND_SLASH

Default: True

When set to True, if the request URL does not match any of the patterns in the URLconf and it doesn’t end in a slash, an HTTP redirect is issued to the same URL with a slash appended. Note that the redirect may cause any data submitted in a POST request to be lost.

Source: http://ift.tt/2fWrOqx

Is it that APPEND_SLASH is True by default even if it's not in settings.py? And that you should only put it in this file if you want to set it to False? Or what's the reason for that behaviour?




Aucun commentaire:

Enregistrer un commentaire