Question

I am using Django REST to create users for my app.

Everywhere i look at, for users they extend AbstractBaseUser. I tried extending the User model, and it seems to work just fine.

I have an PersonalAbstractUser that extends the Django User. Then, Worker and Client extends PersonalAbstractUser. Login and custom permissions seem to work just fine up until now, but i am getting concerned when i see that no one else is extending User...

Why is that? Did i miss something?

Was it helpful?

Solution

This is not a question about Django REST, but about Django itself.

The problem with extending the User object directly is that it is already a concrete model, so extending it will use multi-table inheritance. That's not usually a good idea - especially if you're further extending it.

AbstractUser is an abstract model, but (unlike AbatractBaseUser) contains all the fields that User defines. You should use that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top