I wrapped the django.contrib.auth.views.logout with another function to add additional behaviour. This is my new logout_page:
views.py
from django.contrib.auth import logout
def logout_page(request, *args, **kwargs):
from django.utils import timezone
user = request.user
profile = user.get_profile()
profile.last_logout = timezone.now()
profile.save()
logout(request, *args, **kwargs)
and
urls.py
(r'^logout/$', 'main.views.logout_page', {'next_page': '/'})
But I’m getting the following error:
logout() got an unexpected keyword argument 'next_page'
I’m not sure why is ‘next_page’ an unexpected argument when logout contains **kwargs and as far as I know, logout from django.contrib.auth should contain such argument. From the source:
https://github.com/django/django/blob/master/django/contrib/auth/views.py
def logout(request, next_page=None,
template_name='registration/logged_out.html',
redirect_field_name=REDIRECT_FIELD_NAME,
current_app=None, extra_context=None):
...
How can I solve this?
You’re calling the wrong
logout.should be