takosuke
takosuke

Reputation: 325

django - set_language view giving me a "Page not found" error

Hi there I've been following the docs on internationalization for django (using mezzanine on django 1.2.5) closely and everything is fine, except when i use a form like the one in the docs to switch language code like this

<form action="/i18n/setlang/" method="post">
<input name="next" type="hidden" value="/whatever/" />
<select name="language">
    {% for lang in LANGUAGES %}
    <option value="{{ lang.0 }}">{{ lang.1 }}</option>
    {% endfor %}
</select>
<input type="submit" value="Go" />
</form>

with my urlconf looking like this

urlpatterns += patterns("",
    ("^admin/", include(admin.site.urls)),
    ("^", include("mezzanine.urls")),
    (r'^i18n/', include('django.conf.urls.i18n')),

)

when i switch language and hit "go", i get a

        Page Not Found (404)
        Request Method: POST
        Request URL:    http://127.0.0.1:8000/i18n/setlang/
        No Page matches the given query.

i added the i18n urls and the locale middleware alright.I tried it in a fresh project as well without luck. Any clues?

Upvotes: 3

Views: 2392

Answers (1)

Steve
Steve

Reputation: 1736

Mezzanine's urlpatterns include a "catch all" for pages, so anything underneath it will never be found. To get your patterns working you simply need to swap the last two patterns in your urls.py to look like:

urlpatterns += patterns("",
    ("^admin/", include(admin.site.urls)),
    (r'^i18n/', include('django.conf.urls.i18n')),
    ("^", include("mezzanine.urls")),
)

Upvotes: 6

Related Questions