Allauth Manual Login

I recently switched my authentication system to django-allauth and enabled login via email and password. However, I’ve been encountering persistent issues with manual login, even though both the email (verified) and password are correct. Also, I am currently running django-allauth version 65.7.0.

Note: The user is logged in automatically after signing up, but cannot log in manually after logging out. I can only log in with my superuser username and password in the admin panel.

Below are the updated code from settings.py:

INSTALLED_APPS = [
....
    # 3rd party
    'crispy_forms',
    'crispy_bootstrap5',
    'allauth',
    'allauth.account',
    # local
    'accounts',
    'pages',
    'articles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
....
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'allauth.account.middleware.AccountMiddleware',
]

AUTHENTICATION_BACKEND = (
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
    )

ACCOUNT_LOGIN_METHODS = {'email'}
ACCOUNT_SIGNUP_FIELDS = ['first_name', 'last_name', 'username', 'age', 'email*', 'password1*', 'password2*']

AUTH_USER_MODEL = "accounts.CustomUser"

Additionally, I ran the following tests which all passed. So, I am lost as to why I can’t log in manually even with the correct credentials.

from django.test import TestCase
from django.contrib.auth import get_user_model
from django.urls import reverse

    class SignupPageTest(TestCase):
        email = "testuser@gmail.com"
        password = "testpass123"
        username = "testuser"

        def setUp(self):
             url = reverse("account_signup")
             self.response = self.client.get(url)

        def test_signup_template_is_correct(self):
             self.assertEqual(self.response.status_code, 200)
             self.assertTemplateUsed(self.response, "account/signup.html")

        def test_signup_form_is_correct(self):
             new_user = get_user_model().objects.create_user(username=self.username, email=self.email, password=self.password)
             self.assertEqual(new_user)
             self.assertEqual(get_user_model().objects.all().count(), 1)
             self.assertEqual(get_user_model().objects.all()[0].username, self.username)
             self.assertEqual(get_user_model().objects.all()[0].email, self.email)

        def test_login_successful(self):
             login_user = self.client.login(email=self.email, password=self.password)
             self.assertEqual(login_user)

What do you mean by “cannot login”? You entered the username and password but it shows an error? Or you couldn’t see the login page? Or something else?

I can view the login page, but there is an error of incorrect email/password when I try to sign in manually. Although, I developed a new project using the latest version of django and everything worked fine, but the issue persists on the initial project.

Did your login template/form has account_login on the action ?
<form method="POST" action="{% url 'account_login' %}" class="space-y-4">

This specify your manual login url.

Yes, my login form contains the account_login url name, as shown below;

<form method="post" action="{% url 'account_login' %}">
        {% csrf_token %}
        {{ form|crispy }}
        <button class="btn btn-success" type="submit">Login</button>
</form>

However, the authentication process still mysteriously fails even when the correct email address and password are inputted.