我正在尝试覆盖DJango注销,执行以下操作:
registration_urls.py
urlpatterns = patterns(
'',
url(r'^activate/complete/$',
TemplateView.as_view(
template_name='registration/activation_complete.html'),
name='registration_activation_complete'),
# Activation keys get matched by \w+ instead of the more specific
# [a-fA-F0-9]{40} because a bad activation key should still get to the view
# that way it can return a sensible "invalid key" message instead of a
# confusing 404.
url(r'^activate/(?P<activation_key>\w+)/$',
ActivationView.as_view(),
name='registration_activate'),
url(r'^register/$',
FHRegistrationView.as_view(form_class=RegistrationFormUserProfile),
name='registration_register'),
url(r'^register/complete/$',
TemplateView.as_view(
template_name='registration/registration_complete.html'),
name='registration_complete'),
(r'', include('registration.auth_urls')),
#url(r'^login/$', views.login(template_name='registration/login.html'),{'APP_ROOT': settings.APP_ROOT}),
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'registration/login.html', 'authentication_form': AuthenticationForm }),
url(r'^accounts/logout/$', 'formshare.apps.main.registration_views.LogoutView'),
)
registration_views.py
...
def LogoutView(request):
logout(request)
return render(request, "registration/logout.html",{'APP_ROOT': settings.APP_ROOT})
...
但它似乎不起作用! APP_ROOT在设置中定义,我在许多其他视图和模板中使用它。但是注销模板没有获得变量APP_ROOT
非常感谢任何想法。