title: How to redirect CBV login_required to a specific route?
body: <p>I have a HomeView Class which I added a login_required, but I don't know how to redirect it with the custom login page that I made.</p>
  <p>Here are the urls.py and settings.py in my project:</p>
  <p>myblog\urls.py</p>
  <pre><code>from django.contrib import admin
  from django.urls import path,include
  from .settings import DEBUG, STATIC_URL, STATIC_ROOT, MEDIA_URL, MEDIA_ROOT
  from django.conf.urls.static import static
  # from django.conf import settings
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('', include('myblog_app.urls')),
      path('members/', include('django.contrib.auth.urls')),
      path('members/', include('members.urls')),
  ]
  # + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
  
  if DEBUG:
      urlpatterns += static(STATIC_URL,document_root =STATIC_ROOT )
      urlpatterns += static(MEDIA_URL,document_root = MEDIA_ROOT)
  </code></pre>
  <p>myblog_app\urls.py</p>
  <pre><code>from django.urls import path
  from django.contrib.auth.decorators import login_required
  from .views import HomeView,ArticleDetailView,AddPostView,UpdatePostView,DeletePostView,AddCategoryView,CategoryView,CategoryListView,LikeView,AddCommentView
  
  urlpatterns = [
      path('', login_required(HomeView.as_view()),name='home'),
      path('article/&lt;int:pk&gt;', ArticleDetailView.as_view(),name='article-detail'),
      path('add_post/', AddPostView.as_view(),name='add_post'),
      path('article/&lt;int:pk&gt;/comment/', AddCommentView.as_view(),name='add_comment'),
      path('article/edit/&lt;int:pk&gt;', UpdatePostView.as_view(),name='update_post'),
      path('article/&lt;int:pk&gt;/remove', DeletePostView.as_view(),name='delete_post'),
      path('add_category/', AddCategoryView.as_view(),name='add_category'),
      path('category/&lt;str:cats&gt;', CategoryView,name='category'),
      path('category-list', CategoryListView,name='category_list'),
      path('like/&lt;int:pk&gt;', LikeView,name='like_post'),
  ]
  </code></pre>
  <p>members/urls.py</p>
  <pre><code>from django.urls import path
  from .views import UserRegisterView,UserEditView,UserLoginView,PasswordsChangeView,ShowProfilePageView,EditProfilePageView
  from django.contrib.auth import views as auth_views
  from . import views
  
  urlpatterns = [
      path('login/',UserLoginView, name='login'),
      path('register/',UserRegisterView.as_view(), name='register'),
      path('edit_profile/',UserEditView.as_view(), name='edit_profile'),
      # path('password/',auth_views.PasswordChangeView.as_view(template_name='registration/change-password.html')),
      path('password/',PasswordsChangeView.as_view(template_name='registration/change-password.html')),
      path('password_success/',views.password_success,name='password_success'),
      path('&lt;int:pk&gt;/profile/',ShowProfilePageView.as_view(),name='show_profile_page'),
      path('&lt;int:pk&gt;/edit_profile_page/',EditProfilePageView.as_view(),name='edit_profile_page'),
  ]
  </code></pre>
  <p>settings.py</p>
  <pre><code># Default primary key field type
  # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
  
  DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
  
  LOGIN_REDIRECT_URL='home'
  LOGOUT_REDIRECT_URL='login'
  </code></pre>
  <p>What it's doing now is that it basically just redirects to the
  <code>path('', login_required(HomeView.as_view()),name='home')</code> and it doesn't know where to get the login url from, so instead it should redirect to <code>path('login/',UserLoginView, name='login')</code> but I have no idea how to do it</p>