我不得不改變我的模板稍微做一些URL重定向,所以我用:如何使用url標籤下的腳本標籤
<script>
if window.location="www.somesite.com"{
window.location="www.someothersite.com{% url app.views.some_view argument %}"
}
</script>
但我不斷收到錯誤NoReverseMatch: Reverse for 'app.views.some_view' with arguments 'xxx' and keyword arguments '{}' not found.
我我使用{% load url from future%}
,我確信那個特定的鏈接工作正常,否則沒有Javascript。
您的反向參數應該用引號括起來,如[here]所示(https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std:templatetag-url)。 – ersran9 2013-03-23 20:40:55