Fixed #6213: flatpage view now correctly redirects if settings.APPEND_SLASH. Thanks, crankycoder.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8218 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
98d8acf33f
commit
d0f57e7c73
|
@ -1,7 +1,7 @@
|
||||||
from django.contrib.flatpages.models import FlatPage
|
from django.contrib.flatpages.models import FlatPage
|
||||||
from django.template import loader, RequestContext
|
from django.template import loader, RequestContext
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.xheaders import populate_xheaders
|
from django.core.xheaders import populate_xheaders
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
@ -19,6 +19,8 @@ def flatpage(request, url):
|
||||||
flatpage
|
flatpage
|
||||||
`flatpages.flatpages` object
|
`flatpages.flatpages` object
|
||||||
"""
|
"""
|
||||||
|
if not url.endswith('/') and settings.APPEND_SLASH:
|
||||||
|
return HttpResponseRedirect(url + "/")
|
||||||
if not url.startswith('/'):
|
if not url.startswith('/'):
|
||||||
url = "/" + url
|
url = "/" + url
|
||||||
f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
|
f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
|
||||||
|
|
Loading…
Reference in New Issue