Ticket #6309: apped_slash_flatpages.diff

File apped_slash_flatpages.diff, 1.7 KB (added by Ville Säävuori, 17 years ago)
  • 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
     
    2121    """
    2222    if not url.startswith('/'):
    2323        url = "/" + url
     24    # if APPEND_SLASH=True, will not serve flatpage without a slash
     25    if settings.APPEND_SLASH and not url.endswith('/'):
     26        return HttpResponseRedirect(url + "/")
     27       
    2428    f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
    2529    # If registration is required for accessing this page, and the user isn't
    2630    # logged in, redirect to the login page.
  • docs/flatpages.txt

     
    6363
    6464For more on middleware, read the `middleware docs`_.
    6565
     66**New in Django development version**
     67
     68.. admonition:: Flatpages and ``APPEND_SLASH``
     69
     70    If you use flatpages with ``APPEND_SLASH`` setting turned on, Django will
     71    always append slashshes to flatpage URLs, too.
     72
    6673.. _SITE_ID: ../settings/#site-id
    6774.. _RequestContext: ../templates_python/#subclassing-context-djangocontext
    6875.. _middleware docs: ../middleware/
Back to Top