Hi,
Hope you are all doing well.
I had to change the User object to support several use-cases in my system.
I have created a custom User object that extends AbstractBaseUser.This object only has email, password, last_login and the permissions (is_stuff, is_superuser). I also created UserManager for it.
If I go to the /admin I can create new users and it works well.
However, I have to extends this user, to allow different kind of users:
1. Company
2. Employee
In both cases I hold a onetoone User object reference:
class Employee(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='+')
I read documentation and found places that describe how to add inline nesting in the admin UI, however, in all the scenarios I saw it shows that the inline is done on the User object which then adds part for an Employee.
However, this is not what I want. I would like to enable creating a user via /admin only when creating a Company or Employee.
For Example when I want to create an Employee I will have the following fields:
- email
- password
(these 2 come from the User)
- name
- birthday
(these are coming from the Employee)
Is it possible to achieve?
Thank you,
Elic