2

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)
skg_9
  • 59
  • 5
  • Have you added `AUTH_USER_MODEL = 'users.User'` to your `settings.py` file ? If not add it – Rvector Sep 27 '21 at 19:33
  • Yes, I have already added that. It is working fine in the shell using the get_user_model instance also. issue is with the admin site . – skg_9 Sep 27 '21 at 19:51

1 Answers1

0

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.

skg_9
  • 59
  • 5