The example code is:
{{{#!python
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'len...@thebeatles.com',
'johnpassword')
}}}
But running it in a `python manage.py shell` produces the following error:
{{{#!python
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'len...@thebeatles.com',
'johnpassword')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "XXX/lib/python3.8/site-packages/django/db/models/manager.py", line
187, in __get__
raise AttributeError(
AttributeError: Manager isn't available; 'auth.User' has been swapped for
'core.User'
}}}
Documentation shows the same code example up to the "dev" version.
Witnessed on Django 3.2.12, on Linux
core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch, Python 3.8.10
(default, Nov 14 2022, 12:59:47)
[GCC 9.4.0].
[1] https://docs.djangoproject.com/en/3.2/topics/auth/default/#creating-
users
--
Ticket URL: <https://code.djangoproject.com/ticket/34252>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
> `AttributeError: Manager isn't available; 'auth.User' has been swapped
for 'core.User'`
Your project is using a
[https://docs.djangoproject.com/en/4.1/topics/auth/customizing#substituting-a
-custom-user-model custom user model].
The example passes as given when using the default user (in a fresh
project created with `startproject`, for example).
{{{
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'len...@thebeatles.com',
'johnpassword')
>>> user
<User: john>
}}}
Please see TicketClosingReasons/UseSupportChannels if you need further
clarification.
--
Ticket URL: <https://code.djangoproject.com/ticket/34252#comment:1>