我django.contrib.auth.views.logout
用另一个函数包装了它以添加其他行为。这是我的新 logout_page:
视图.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)
和
网址.py
(r'^logout/$', 'main.views.logout_page', {'next_page': '/'})
但我收到以下错误:
logout() got an unexpected keyword argument 'next_page'
当注销包含 **kwargs 并且据我所知,从 django.contrib.auth 注销时,我不确定为什么 'next_page' 是一个意外参数。从来源:
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):
...
我该如何解决这个问题?