1from django.conf import settings
2from django.contrib.auth import get_user_model
3from django.db import models
4
5def get_sentinel_user():
6 return get_user_model().objects.get_or_create(username='deleted')[0]
7
8class MyModel(models.Model):
9 user = models.ForeignKey(
10 settings.AUTH_USER_MODEL,
11 on_delete=models.SET(get_sentinel_user),
12 )
13