From 196ac8f8b31302d026af6d79f764c8f146a8c78e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 20 Apr 2011 14:41:47 +0000 Subject: Fixed #6213 -- Updated the flatpages app to only append a slash if the flatpage actually exist. The FlatpageFallbackMiddleware (and the view) now only add a trailing slash and redirect if the resulting URL refers to an existing flatpage. Previously requesting /notaflatpageoravalidurl would redirect to /notaflatpageoravalidurl/, which would then raise a 404. Requesting /notaflatpageoravalidurl now will immediately raise a 404. Also, Redirects returned by flatpages are now permanent (301 status code) to match the behaviour of the CommonMiddleware. Thanks to Steve Losh for the initial work on the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16048 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/contrib/flatpages.txt | 12 ++++++++++++ docs/releases/1.4.txt | 13 +++++++++++++ 2 files changed, 25 insertions(+) (limited to 'docs') diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt index 0411e8f93f..a99f75eb2d 100644 --- a/docs/ref/contrib/flatpages.txt +++ b/docs/ref/contrib/flatpages.txt @@ -77,6 +77,18 @@ does all of the work. :class:`~django.template.RequestContext` in rendering the template. + .. versionchanged:: 1.4 + The middleware will only add a trailing slash and redirect (by looking + at the :setting:`APPEND_SLASH` setting) if the resulting URL refers to + a valid flatpage. Previously requesting a non-existent flatpage + would redirect to the same URL with an apppended slash first and + subsequently raise a 404. + + .. versionchanged:: 1.4 + Redirects by the middlware are permanent (301 status code) instead of + temporary (302) to match behaviour of the + :class:`~django.middleware.common.CommonMiddleware`. + If it doesn't find a match, the request continues to be processed as usual. The middleware only gets activated for 404s -- not for 500s or responses diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index 56a5919505..9de896d33d 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -78,3 +78,16 @@ Django instance, and try to submit it to the upgraded Django instance: * time period: the amount of time you expect user to take filling out such forms. + +django.contrib.flatpages +~~~~~~~~~~~~~~~~~~~~~~~~ + +Starting in the 1.4 release the +:class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware` only +adds a trailing slash and redirects if the resulting URL refers to an existing +flatpage. For example, requesting ``/notaflatpageoravalidurl`` in a previous +version would redirect to ``/notaflatpageoravalidurl/``, which would +subsequently raise a 404. Requesting ``/notaflatpageoravalidurl`` now will +immediately raise a 404. Additionally redirects returned by flatpages are now +permanent (301 status code) to match the behaviour of the +:class:`~django.middleware.common.CommonMiddleware`. -- cgit v1.3