Sorry if the title of this question sucks but I couldn't find much info on this particular problem. In the docs, the code below is given:
from django.db import models
from django.contrib.auth.models import User
def get_sentinel_user():
return User.objects.get_or_create(username='deleted')[0]
class MyModel(models.Model):
user = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user))
In such a scenario, is there any way by which I can make MyModel delete itself depending on the return value of get_sentinel_user?