Is it easy to switch User model from inheriting AbstractUser to AbstractBaseUser if already in production?

34 views
Skip to first unread message

Tyler Lynch

unread,
Jan 20, 2019, 10:54:19 AM1/20/19
to Django users
Just wondering how difficult that switch is? 

I know, for example, that it's best practice to atleast set AUTH_USER_MODEL to a custom user model that inherits from AbstractUser, because switching this setting afterwards is difficult, because of updating all the foreign keys, etc.

But if that is already implemented, how difficult is it to switch the user model from inheriting AbstractUser to AbstractBaseUser? 

Is it simply a matter of bringing in the similar fields, methods as the normal django user, inheriting PermissionsMixin as well and likewise with the UserManager? 

Or does it also involve having to manually update foreign keys or otherwise do some diving in the database?

Just wondering, because if it is that easy, then it's no problem to just inherit from AbstractUser now but I can switch to AbstractBaseUser if my project needs change. Otherwise, I'll just start with AbstractBaseUser, which doesn't seem all that bad to extend actually. I guess the danger is that, when upgrading to new django versions, have to be careful to manually reintroduce any new patches to the user code? 

Thanks and sorry if the question is a bit rambling. 
Reply all
Reply to author
Forward
0 new messages