I have a Django project in which I need a custom user, I followed the steps of Django Documentation to achieve a custom User but Super User shares the same properties. I really dont need those for my admin users. Is there a way to have a specific Model for Admins and Users?
Asked
Active
Viewed 191 times
1 Answers
0
Here as you can see, Django user has two property is_staff
and is_superuser
, admin users should have value True
for those property(like: user.is_superuser=True
) and normal users can have it False
, that can distinguish Admins from Users, other properties like first_name, last_name etc can be shared by both parties.
Otherwise, you can add your own property: ex:
class SomeUser(User):
is_admin= models.NullBooleanField(default=False, null=True)
or like:
class SomeUser(models.Model):
user=models.OneToOneField(User)
is_admin= models.NullBooleanField(default=False, null=True)
#I prefer like this way of using customizing authentication

ruddra
- 50,746
- 7
- 78
- 101