title: Proper way to add code to logout view in Django
body: <p>I wrapped the <code>django.contrib.auth.views.logout</code> with another function to add additional behaviour. This is my new logout_page:</p>
  
  <p>views.py</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>and </p>
  
  <p>urls.py</p>
  
  <pre><code>(r'^logout/$', 'main.views.logout_page', {'next_page': '/'})
  </code></pre>
  
  <p>But I'm getting the following error:</p>
  
  <pre><code>logout() got an unexpected keyword argument 'next_page'
  </code></pre>
  
  <p>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:</p>
  
  <p><a href="https://github.com/django/django/blob/master/django/contrib/auth/views.py" rel="nofollow">https://github.com/django/django/blob/master/django/contrib/auth/views.py</a></p>
  
  <pre><code>def logout(request, next_page=None,
             template_name='registration/logged_out.html',
             redirect_field_name=REDIRECT_FIELD_NAME,
             current_app=None, extra_context=None):
  ...
  </code></pre>
  
  <p>How can I solve this?</p>