在项目urls.py中:
urlpatterns = [
path('admin/', admin.site.urls),
url(r'^', include('blog.urls'), ),
url(r'login/$', userviews.UserLoginView.as_view(), name='login'),
url(r'logout/$', userviews.UserLogoutView.as_view(), name='logout'),
url(r'signup/$', userviews.SignupView.as_view(), name='signup'),
url(r'^hello/$', userviews.test, name='test')
]
在应用中:用户:
class UserLoginView(LoginView):
template_name = 'login.html'
success_url = reverse_lazy('test')
redirect_field_name = reverse_lazy('test')
用户中没有urls.py。
the function below works:
def get_success_url(self):
url = super(UserLoginView, self).get_success_url()
print(url)
return self.success_url
所以我只想知道,如果我没有设置,它将重定向到success_url LOGIN_REDIRECT_URL还是覆盖get_success_url?