3

In my Django Rest Framework api I have no human users which interact with my api, but I would like to use the User authentication on these machine users. However, the AbstractBaseUser still locks me in to much with the required email and username (which do not make sense for my machine users). Also, I would like to have human admins (superusers) but by customizing with AbstractBaseUser the superuser also changes. Can I separate the User for authentication from the superuser I want to use in the admin?

I have already tried to use a OneToOne link with user in my machine user model as a profile but this still means I need to conform to django's user. Also, I have tried to use AbstractBaseUser but this creates the problems mentioned above.

The model that should be my User model as this creates another resource (receipts)

class ReceiptMachine(models.Model):
    machine_user = models.OneToOneField('ReceiptUser',  on_delete=models.CASCADE)
    machine_id = models.UUIDField(verbose_name='id of receipt machine', default=uuid.uuid4, editable=False, unique=True)
    store = models.ForeignKey('Store', on_delete=models.CASCADE, to_field='store_id')

class ReceiptUser(AbstractBaseUser):
    ? 

So I want to use this model as my Authentication via the Django user but I would also like to retain the normal admin superuser.

0 Answers0