开发者

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.

开发者_StackOverflow中文版i added the i18n urls and the locale middleware alright.I tried it in a fresh project as well without luck. Any clues?


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")),
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜