[Django] #34252: Doc page "Using the Django authentication system" shows failing example

7 views
Skip to first unread message

Django

unread,
Jan 11, 2023, 9:04:04 AM1/11/23
to django-...@googlegroups.com
#34252: Doc page "Using the Django authentication system" shows failing example
-----------------------------------------+------------------------
Reporter: jdreo | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The "Using the Django authentication system" documentation page, in the
"Creating user" section [1], shows an example of how to create users
manually.
However, this example fails.

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.

Django

unread,
Jan 11, 2023, 9:18:18 AM1/11/23
to django-...@googlegroups.com
#34252: Doc page "Using the Django authentication system" shows failing example
-------------------------------+--------------------------------------
Reporter: jdreo | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* 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>

Reply all
Reply to author
Forward
0 new messages