I have two models:
class CustomUser(models.Model):
...
act = models.CharField(max_length=10)
class ActHistory(models.Model):
user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
last_act = models.CharField(max_length=10)
act_time = models.DateTimeField(auto_now_add=True)
I would like to create a single API endpoint /update/ with DRF that does this:
- If value vs existing act value in the model is the same, do nothing.
- If the values are different, update the CustomUser for the authenticated user with the value
- Then insert a record row in ActHistory with user=authenticated user, last_act =
All the docs I managed to find only support doing either the update or create actions with each API point.
Thanks in advance!