I have created models like this
class User(AbstractUser):
login_count = models.PositiveIntegerField(default=0)
class Supplier(User):
company_name= models.CharField(max_length=30)
company_domain=models.CharField(max_length=30)
class Worker(User):
ACCOUNT_TYPE = (
('1', 'Admin'),
('2', 'Regular'),
)
account_type = models.CharField(max_length=1, choices=ACCOUNT_TYPE)
and in the users.admin.py, I have
admin.site.register(Supplier)
admin.site.register(Worker)
Why is it that I have all models names as Users in the Django Admin? instead of Workers and Suppliers?
Because AbstractUser
is an abstract model it's Meta
class is inherited by all subclasses, docs.
You need to provide your own Meta
class for each model and pass the verbose_name
and verbose_name_plural
attributes to override the values set in AbstractUser
s Meta
class
class Supplier(User):
company_name = models.CharField(max_length=30)
company_domain = models.CharField(max_length=30)
class Meta:
verbose_name = 'supplier'
verbose_name_plural = 'suppliers'
class Worker(User):
ACCOUNT_TYPE = (
('1', 'Admin'),
('2', 'Regular'),
)
account_type = models.CharField(max_length=1, choices=ACCOUNT_TYPE)
class Meta:
verbose_name = 'worker'
verbose_name_plural = 'workers'