#31330: Flatpage catchall is killing APPEND_SLASH functionality on normal pages
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
meesterguyman |
Type: | Status: new
Uncategorized |
Component: | Version: 3.0
Uncategorized | Keywords: append_slash,
Severity: Normal | flatpage, catchall
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
We would like to append slashes to all URLs that do not have them, and we
would also like to have a catchall flatpage expression, so our editors can
enter whatever they like in that area of the CMS. The problem is that the
flatpage validator adds the slash, but then only checks to see if a
Flatpage exists for the resultant path
(https://github.com/django/django/blob/master/django/contrib/flatpages/views.py#L41),
whereas the is_valid_path method
(https://github.com/django/django/blob/b9cf764be62e77b4777b3a75ec256f6209a57671/django/urls/base.py#L150)
checks the urlconf, of which the catchall is a part, returns True, because
the non-slash url fits the catchall. Hence, it does not redirect to the
slashed version, making it impossible to reach and resulting in a 404.
Again, here is the flow:
1. Attempt to reach "/my-valid-page-without-a-slash"
2. is_valid_path returns True because "/my-valid-page-without-a-slash"
fits the flatpage catchall and hence does not append a slash
3. The page is not found in Flatpage entries, resulting in 404
It seems to me that if APPEND_SLASH is set to True, then we should not be
looking in the urlconf for the page without the slash, but should instead
immediately append the slash, then check the urlconf, in which case the
correct pattern would be found and flatpages would never be called.
--
Ticket URL: <https://code.djangoproject.com/ticket/31330>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.3fe7e8f6f8dd3b6d01e01d57d05c69c7%40djangoproject.com.