Search code examples
pythondjangodjango-middlewaredjango-i18n

Django LocaleMiddleware does not add slash with APPEND_SLASH enabled


I've encountered a problem using LocaleMiddleware in django 1.6. It does not add extra slash event if settings.APPEND_SLASH is set to True. The text error text is:

Request Method:   GET 
Request URL:  http://pollina.ru/ua/add
Django Version:   1.6.2 
Exception Type:   DoesNotExist 
Exception Value:   Poll matching query does not exist.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/query.py

in get, line 307

As far as I understand the django engine does not event reach the LocaleMiddleware that appends slash to url. my urlconf looks like this

urlpatterns = i18n_patterns('',
    url(r'^$',MainPage.as_view(),name="mainpage"),
    url(r'^add/$', PollCreator.as_view(),name="addpoll"),
    ..........
)

So how can I make django engine reach the LocaleMiddleware and make it rewrite url by appending extra slash to my url


Solution

  • The question is closed. The problem was that other regexps that were defined after the:

        url(r'^add/$', PollCreator.as_view(),name="addpoll"),
    

    matched that url but did not respond properly