Django does not log in custom superuser with correct password and username [closed]

I know this is a recurrent question but my case is pretty weird.

I am working with a partner and on his laptop (with Linux) everything is going well. However, I tried to run the same code two times: one on Windows and the other one on Archlinux and in both of them I am not able to log in with the correct username and password.

The superuser was created with 'python createsuperuser' the there weren't errors in the console. Superuser with its password (hashed) is correctly written in PostgreSQL database, so I suspect that the problem is in the reading or with the desencryptation. I copy and

from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
from django.contrib.auth import get_user_model
from django.utils import timezone

class AccountManager(BaseUserManager):
    use_in_migrations = True

    def _create_user(self, email, password, **extra_fields):
        values = [email]
        field_value_map = dict(zip(self.model.REQUIRED_FIELDS, values))
        for field_name, value in field_value_map.items():
            if not value:
                raise ValueError('The {} value must be set'.format(field_name))

        email = self.normalize_email(email)
        user = self.model(
        return user

    def create_user(self, email, password=None, **extra_fields):
        extra_fields.setdefault('is_staff', False)
        extra_fields.setdefault('is_superuser', False)
        return self._create_user(email, password, **extra_fields)

    def create_superuser(self, email, password=None, **extra_fields):
        extra_fields.setdefault('is_staff', True)
        extra_fields.setdefault('is_superuser', True)

        if extra_fields.get('is_staff') is not True:
            raise ValueError('Superuser must have is_staff=True.')
        if extra_fields.get('is_superuser') is not True:
            raise ValueError('Superuser must have is_superuser=True.')

        return self._create_user(email, password, **extra_fields)

class Account(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(verbose_name="Correo electrónico", max_length=255, unique=True)
    nombre              =models.CharField(max_length=45,blank=False, null=True)
    apellido            =models.CharField(max_length=45,blank=False, null=True)
    telefono            =models.CharField(max_length=15,blank=True)
    date_join           =models.DateTimeField(verbose_name='Fecha de alta', auto_now_add=True)
    last_login          =models.DateTimeField(verbose_name='Última conexión', auto_now=True)
    is_teacher          =models.BooleanField(default=False)
    is_student         =models.BooleanField(default=False)
    is_authority        =models.BooleanField(default=False)
    is_guard            =models.BooleanField(default=False)
    is_parent           =models.BooleanField(default=False)
    is_staff            =models.BooleanField(default=False)
    is_active           =models.BooleanField(default=False)
    is_admin           =models.BooleanField(default=False)
    is_superuser        =models.BooleanField(default=False)

    objects = AccountManager()

    USERNAME_FIELD = 'email'

    def __str__(self):

#    def get_full_name(self):
#        return

#    def get_short_name(self):
#        return[0]


Also, it is relevant to mention that it is declared on my AUTH_USER_MODEL = 'accounts.Account'

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin

from .models import Account
from .forms import UserCreationForm, UserChangeForm

class AccountAdmin(BaseUserAdmin):
    form = UserChangeForm
    add_form = UserCreationForm

    list_display = ('email','nombre' , 'apellido', 'telefono', 'is_staff',  'is_superuser')
    list_filter = ('is_superuser',)

    fieldsets = (
        (None, {'fields': ('email', 'is_staff', 'is_superuser', 'password')}),
        ('Personal info', {'fields': ('nombre', 'apellido', 'telefono')}),
        ('Groups', {'fields': ('groups',)}),
        ('Permissions', {'fields': ('user_permissions',)}),
    add_fieldsets = (
        (None, {'fields': ('email','is_teacher','is_student','is_authority','is_guard','is_parent','is_staff','is_admin','is_superuser', 'password1', 'password2')}),
        ('Groups', {'fields': ('groups',)}),
        ('Permissions', {'fields': ('user_permissions',)}),

    list_display = ('email', 'nombre' , 'apellido')

    search_fields = ('email', 'nombre', 'apellido')
    ordering = ('apellido','nombre','email',)
    filter_horizontal = (), AccountAdmin)
Back to Top