diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index b5233e4ff4..b8b008c4f3 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1254,14 +1254,16 @@ The possible values for :attr:`~ForeignKey.on_delete` are found in necessary to avoid executing queries at the time your models.py is imported:: + from django.conf import settings + from django.contrib.auth import get_user_model 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] + return get_user_model().objects.get_or_create(username='deleted')[0] class MyModel(models.Model): - user = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user)) + user = models.ForeignKey(settings.AUTH_USER_MODEL, + on_delete=models.SET(get_sentinel_user)) * .. attribute:: DO_NOTHING @@ -1515,12 +1517,12 @@ as default value. With the following example:: + from django.conf import settings from django.db import models - from django.contrib.auth.models import User class MySpecialUser(models.Model): - user = models.OneToOneField(User) - supervisor = models.OneToOneField(User, related_name='supervisor_of') + user = models.OneToOneField(settings.AUTH_USER_MODEL) + supervisor = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='supervisor_of') your resulting ``User`` model will have the following attributes::