Ticket #16805: flatpages_modify_status_code.patch

File flatpages_modify_status_code.patch, 973 bytes (added by Domen Kožar, 13 years ago)

set status_code to 200 if flatpage was found

  • django/contrib/flatpages/middleware.py

    diff --git a/django/contrib/flatpages/middleware.py b/django/contrib/flatpages/middleware.py
    index fb98c39..869e1cb 100644
    a b class FlatpageFallbackMiddleware(object):  
    77        if response.status_code != 404:
    88            return response # No need to check for a flatpage for non-404 responses.
    99        try:
    10             return flatpage(request, request.path_info)
     10            res = flatpage(request, request.path_info)
    1111        # Return the original response if any errors happened. Because this
    1212        # is a middleware, we can't assume the errors will be caught elsewhere.
    1313        except Http404:
    14             return response
     14            res = response
    1515        except:
    1616            if settings.DEBUG:
    1717                raise
    18             return response
     18            res = response
     19        else:
     20            response.status_code = 200
     21
     22        return res
Back to Top