Adding my results for django 2.0, as the previous answer in this thread no longer works for the latest version of django.
Since 2.0, the correct way to add a URL to your urls.py file is with path ():
from django.urls import path from django.contrib.auth import views as auth_views path('accounts/logout/', auth_views.LogoutView.as_view( extra_context={'foo':'bar'} )),
The .as_view () function is highlighted in this code snippet. Django 2.0 implements auth views as classes. For more information, see Authentication Documentation.
Then you βconvertβ the class into a view using `.as_view (), and you can pass the class attributes defined in the source code as named parameters.
Passing to extra_context (None by default) automatically provides these context variables to your templates.
You can access the source code for LogoutView by following this python path: django.contrib.auth.views
Here you can see other class attributes that you can pass to LogoutView and other auth view classes.
source share