I have the following django model:
class Listing(models.Model):
STATUS_CHOICES = [
('available', 'Available'),
('rented', 'Rented'),
('unavailable', 'Unavailable'),
('fake', 'Fake'),
]
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=200)
description = models.TextField()
status = models.CharField(max_length=12, choices=STATUS_CHOICES, default='available')
def save(self, *args, **kwargs):
##
if self.status == 'fake' and ......:
raise PermissionDenied("Cannot save listing with 'fake' status for non-admin users.")
super().save(*args, **kwargs)
I wander how I can get the current authenticated user to see if that user is superuser then they can set the status to fake, others cannot.
I
I try to see what is in args and kwargs. But they are empty