我正在尝试使用以下代码实现即时语言更改:
{% for lang in LANGUAGES %}
<li>
<form name="setLang{{ lang.1}}" action="/i18n/setlang/" method="POST">{% csrf_token %}
<input name="next" type="hidden" value="http://google.com" />
<input type="hidden" name="language" value="{{ lang.0 }}" />
<a href="#" {% if LANGUAGE_CODE = lang.0 %} class="active" {%endif%} onclick="document.setLang{{ lang.1 }}.submit();return false;">{{ lang.0 }}</a>
</form>
</li>
{% endfor %}
它很好用,问题是它不会返回到“下一个”字段中指定的 URL。我强迫它成为“google.com”只是为了看看它是如何工作的,但它不断将我重定向回我的主页。
这是我的 urls.py:
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'izolyatsia.views.home', name='home'),
# url(r'^izolyatsia/', include('izolyatsia.foo.urls')),
url(r'^$', 'showcase.views.home', name='home'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^project/(?P<project_name>[a-zA-Z0-9_.-]+)/$', 'izolyatsia.views.project'),
(r'^post/(?P<slug>[a-zA-Z0-9_.-]+)/$', 'izolyatsia.views.post'),
#Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
(r'^tinymce/', include('tinymce.urls')),
url(r'^wysiwyg_post/$', 'izolyatsia.views.wysiwyg_post', name='wysiwyg_post'),
url(r'', include('multiuploader.urls')),
(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^(.*)/$', 'pages.views.show_page', name='show_page'),
)
我不知道为什么它不起作用,也许这里有人可以帮助我?
在此先感谢,米。