Search code examples
djangodjango-modelsdjango-usersdjango-managers

Django Custom User Manager is not called in admin panel


I am implementing a custom user model using AbstractBaseUser and BaseUserManaer .

class UserManager(BaseUserManager):
    def create_user(self,username,password=None):


class User(AbstractBaseUser):
    ...

    objects = UserManager()

When I am creating new users from the the terminal, it is working as intended and the users are getting registered using the custom UserManager. But when using the admin site, the user seems to be using some other user manager, where it should be using the custom user manager.

users/admin.py

User = get_user_model()


class UserAdmin(BaseUserAdmin):
     ...

admin.site.register(User, UserAdmin)

Solution

  • Finally got the solution. What I was missing was that the modelform in admin site uses it's own save and update method. So had to change those methods as well. Silly me.