Probably the problem is that the password is not saved correctly with the create
method.
Instead try doing this
u=CustomUser.objects.create(username='root1')
u.set_password('root')
u.save()
Then
authenticate(username='root1', password='root')
will work (at least it worked in my case).
Update: Also, please take a look at the create_user
of the
django ducmentation custom user:
def create_user(self, email, date_of_birth, password=None):
# [...]
user = self.model(
email=self.normalize_email(email),
date_of_birth=date_of_birth,
)
# Explicitly set password with the set_password method
user.set_password(password)
user.save(using=self._db)
return user
So you should not use CustomUser.objects.create
to set the password.