26π
β
Two things:
- django.contrib.auth.views.logout() takes an optional next_page which you are not providing
- url templatetag has comma-separated arguments
So, first modify your url to accept next_page
Your URLConf needs modification to pass in the next page, something like this for a hard-coded redirect:
url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='auth_logout'),
and one parameterized result:
url(r'^logout/(?P<next_page>.*)/$', 'django.contrib.auth.views.logout', name='auth_logout_next'),
And then modify your template to pass in the next_page
<a href="{% url auth_logout_next /some/location %}">Logout</a>
π€hughdbrown
28π
For what itβs worth, I use this:
<a href="{% url auth_logout %}?next=/">Logout</a>
π€Sander Smits
9π
Sander Smits has the most easy solution. In your case use:
<a href="{% url "auth_logout" %}?next={{ request.path|urlencode }}">Logout</a>
And in a more general case, use:
<a href="{% url "auth_logout" %}?next={% url "my_url" my_params |urlencode %}">Logout</a>
π€Wim Feijen
- Sending a message to a single user using django-channels
- How does django-nose differ from the default Django test-runner
- Installing django 1.5(development version) in virtualenv
- Accessing django project in LAN systems
- Is there a way to render a html page without view model?
0π
If anyone wants to give out an HTML link through views.py validation error with mark_safe and translations.
I used this part to logout the user and then send him to the password recorve page.
mark_safe(_("Error message") + '<a href="' + reverse('logout') + '?next=' + reverse('password_recover') + '">' + ugettext("Forgot password?") + '</a>')
π€Dude
Source:stackexchange.com