problems with auth.login

i am building a custom login app with django and postgres, i wrote a login_view when django tries to login in to da db it crash :

@csrf_protect
def logins(request):
{csrf_token}
if request.method == ‘POST’:
info = UserInfo()
username = request.POST[‘username’]
password = request.POST[‘password’]
user = auth.authenticate(username=username, password=password)
if user is not None:
info.user_name = username
auth.login(request, user) # i get blocked here
if request.user.is_superuser:
info.user_role = True
return render(request, “dashboard.html”, {‘info’: info})
else:
return render(request, “dashboard.html”, {‘info’: info})
else:
return redirect(’/’)
else:
return redirect(’/’)

but when i write into the search bar of the browser : http://127.0.0.1:8000/admin/ , it take me to the default dashboard admin of django, so i dont understand why my custom login page dont work

You need to “intercept” the /admin/login/ url and direct it to your view.

Normally, when using the admin facility, you’ll have an entry in your base urls.py file that looks like this:
path('admin/', admin.site.urls),

Before that line, you should be able to insert an entry:
path('admin/login/', views.logins, name='login'),

This will catch any reference to that url and direct it to your view instead of it being handled by the admin login process.