login_required decorator

If login_required decorator is used, and the django project is under sub-site, settings.LOGIN_URL and settings.LOGIN_REDIRECTED_URL can be set with url name in urls.py as following:

urlpatterns = [
  url(r'^$', views.HomeView.as_view(), name="homepage"),
  url(r'^loing/$', auth_views.login, name="login"),
  ...
]

define urls for login and homepage and the name can be used in settings.py as:

LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'homepage'

without ‘/’, it refers the url.name.