2011-09-27 55 views
0

我有一個基於https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.logout用GET Django的註銷URL值

這裏的URL配置是:

url(r'^logout(?P<next_page>.*)$', 'logout', name='auth_logout_next'), 

在模板我用這樣的代碼:

<a href="{% url auth_logout_next request.path %}">{% trans "Logout" %}</a> 

它的工作原理很好,但我在某些頁面上有可能的GET值 - ?page=2,所以request.path會刪除這些值。我應該如何通過不僅現有的頁面,而且如果可能的話,也通過GET值。

回答

3
<a href="{% url auth_logout_next request.get_full_path|urlencode %}">{% trans "Logout" %}</a>