Ticket #7257: flatpages.patch

File flatpages.patch, 955 bytes (added by crankycoder@…, 7 years ago)

flatpages patch to force redirects if APPEND_SLASH is enabled in settings.py

  • django/contrib/flatpages/views.py

     
    11from django.contrib.flatpages.models import FlatPage
    22from django.template import loader, RequestContext
    33from django.shortcuts import get_object_or_404
    4 from django.http import HttpResponse
     4from django.http import HttpResponse, HttpResponseRedirect
    55from django.conf import settings
    66from django.core.xheaders import populate_xheaders
    77from django.utils.safestring import mark_safe
     
    1919        flatpage
    2020            `flatpages.flatpages` object
    2121    """
     22    if not url.endswith('/') and settings.APPEND_SLASH:
     23        return HttpResponseRedirect(url + "/")
    2224    if not url.startswith('/'):
    2325        url = "/" + url
    2426    f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
Back to Top