Opened 2 years ago
Closed 2 years ago
#34252 closed Bug (invalid)
Doc page "Using the Django authentication system" shows failing example
Reported by: | Johann Dreo | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 3.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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:
>>> from django.contrib.auth.models import User >>> user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
But running it in a python manage.py shell
produces the following error:
>>> from django.contrib.auth.models import User >>> user = User.objects.create_user('john', 'lennon@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
Your project is using a custom user model.
The example passes as given when using the default user (in a fresh project created with
startproject
, for example).Please see TicketClosingReasons/UseSupportChannels if you need further clarification.