Applying decorator on a custom view from the file

Hi there,
I’m using the LoginView from the package django.contrib.auth views to render my login page.
That gives me the ability to directly create the url, and the template associated, without creating a custom view.

from django.contrib.auth import views as auth_views
path('connexion/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),

The thing is, I built a decorator that make the unauthenticated pages for unauthenticated users only (ex: logged in users shall not access the login page) :

def unauthenticated_user(view_func):
    def wrapper_func(request, *args, **kwargs):
        if request.user.is_authenticated:
            return redirect('home')
            return view_func(request, *args, **kwargs)

    return wrapper_func

So I placed this decorator on top of each view that is concerned by this behavior, but I’m unable to do it for the login view (because I don’t have it anywhere in my files).
How can I apply this decorator to the login view?

You typically don’t use a decorator with the Class-Based Views. Security mechanisms are generally done by using a Mixin on the class.

But, neither of these are, strictly speaking for this particular requirement, necessary.

See: redirect_authenticated_user