From 9d1c5088bdd469e750e2f37caa392e0b956f80b2 Mon Sep 17 00:00:00 2001 From: Raul Cumplido Date: Thu, 30 Oct 2014 10:27:19 +0000 Subject: [PATCH] [1.7.x] Fixed #23725 -- Substituted AUTH_USER_MODEL for User in docs. Backport of 68d3db8a7b from master --- docs/ref/models/fields.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 11fcf1bef6..2d7d3c7363 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1237,14 +1237,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 @@ -1498,12 +1500,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::