﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32837	Flatpages manipulates url before get_object_or_404 leads to error	Snake-Soft	nobody	"Django flatpages has some unwanted behaviour can lead to a catched exception that is not easy to resolve.
This problem occurs when saving a FlatPage object without a leading slash in the url.

The view is located in:
 django.contrib.flatpages.views

This is the problematic flatpage view:
{{{
def flatpage(request, url):
    if not url.startswith('/'):
        url = '/' + url
    site_id = get_current_site(request).id
    try:
        f = get_object_or_404(FlatPage, url=url, sites=site_id)
    except Http404:
        if not url.endswith('/') and settings.APPEND_SLASH:
            url += '/'
            f = get_object_or_404(FlatPage, url=url, sites=site_id)
            return HttpResponsePermanentRedirect('%s/' % request.path)
        else:
            raise
    return render_flatpage(request, f)
}}}


I think it doesn't make sense to manipulate the url at this point because nothing happens with the url between manipulating an fetching the FlatPage from db."	Bug	closed	contrib.flatpages	3.1	Normal	invalid			Unreviewed	0	0	0	0	0	0
