[Fixed]-Django: unbound method is_authenticated() must be called with AbstractBaseUser instance

1๐Ÿ‘

โœ…

I am not sure how this ever worked, but I can see why youโ€™d get that error. In django-mongoengine/mongo_auth/models.py I see this:

class BaseUser(object):

    is_anonymous = AbstractBaseUser.is_anonymous
    is_authenticated = AbstractBaseUser.is_authenticated

class User(BaseUser, document.Document):
    ...

which seems to be the source of the error.

You can make it work by modifying that library so that the User class implements those methods directly:

class User(document.Document):
    ...
    def is_anonymous(self):
        """
        Always returns False. This is a way of comparing User objects to
        anonymous users.
        """
        return False

    def is_authenticated(self):
        """
        Always return True. This is a way to tell if the user has been
        authenticated in templates.
        """
        return True
๐Ÿ‘คJessamyn Smith

Leave a comment