django on delete rules

Solutions on MaxInterview for django on delete rules by the best coders in the world

showing results for - "django on delete rules"
Gertrude
03 Jul 2020
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
similar questions
queries leading to this page
django on delete rules