[1.7.x] Fixed #23725 -- Substituted AUTH_USER_MODEL for User in docs.

Backport of 68d3db8a7b from master
This commit is contained in:
Raul Cumplido 2014-10-30 10:27:19 +00:00 committed by Tim Graham
parent 92628cc982
commit 9d1c5088bd
1 changed files with 8 additions and 6 deletions

View File

@ -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::