Django users,
Which way is preferred to customize Django built-in views such as LoginView:
- Define a line in urls.py:
path(route='login/', view=views.django_auth_views.LoginView.as_view(template_name='accounts/login.html', authentication_form=forms.LoginForm, extra_context=None, redirect_authenticated_user=True), name='login'),
Where, views.py contains:
from django.contrib.auth import views as django_auth_views
Or:
In views.py, define a new class:
class LoginView(django_auth_views.LoginView):
template_name = 'accounts/login.html'
authentication_form = LoginForm
extra_context = None
redirect_authenticated_user = True
And then, define in urls.py:
path(route='login/', view=views.LoginView.as_view(), name='login'),
Will both ways work the same, and is one of them preferred from a software engineering / programming perspective?
Thanks,
Uri.
אורי