Задать вопрос

Тел: +7 965 3737 888

501

Просмотров

0

Ответов

Smart append slash middleware

<p>This middleware replaces the behavior of the APPEND_SLASH setting in the CommonMiddleware. Please set APPEND_SLASH = False and SMART_APPEND_SLASH = True if you are going to use this middleware.</p>
<p>In your URL patterns, omit the trailing slash for URLs you want accessible without the slash. Include the slash for those URLs you wish to be automatically redirected from an URL with the slash missing.</p>
<p>If a URL pattern exists both with and without a slash, they are treated as two distinct URLs and no redirection is done.</p>
<p>Example</p>
urlpatterns = patterns('some_site.some_app.views',
    (r'^test/no_append$','test_no_append'),
    (r'^test/append/$','test_append'),
    (r'^test/distinct_url$', 'view_one'),
    (r'^test/distinct_url/$', 'view_two'), )

<p>Behavior of URLs against the above patterns with SMART_APPEND_SLASH enabled:</p>
http://some_site/test/no_append     &#8594; test_no_append()
http://some_site/test/no_append/    &#8594; 404
http://some_site/test/append        &#8594; http://some_site/test/append/
http://some_site/test/append/       &#8594; test_append()
http://some_site/test/distinct_url  &#8594; view_one()
http://some_site/test/distinct_url/ &#8594; view_two()

<p>This module is also available <a href="http://trac.ambitone.com/ambidjangolib/browser/trunk/middleware/common.py">in our SVN repository</a>.</p>

Вопрос полезен? Да0/Нет0
file_4527.py(2.0Кб)
None