Skip to content

Commit 1172bef

Browse files
committed
Update customizing.txt
The origin statement "which could be ... or whatever" **misguides** many newbies like me. In fact, the ``login`` function in ``contrib.auth`` stores ``user.pk`` in session, then ``get_user`` function in ``contrib.auth`` gets ``user.pk`` in session and then passes it to your custom ``get_user`` as ``user_id``. Which means, ``user_id`` prarameter in your custom ``get_user`` has to be the primary key of ``User`` object, too.
1 parent 9012833 commit 1172bef

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/topics/auth/customizing.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ An authentication backend is a class that implements two required methods:
9595
optional permission related :ref:`authorization methods <authorization_methods>`.
9696

9797
The ``get_user`` method takes a ``user_id`` -- which could be a username,
98-
database ID or whatever -- and returns a ``User`` object.
98+
database ID or whatever, but has to be the primary key of your ``User`` object
99+
-- and returns a ``User`` object.
99100

100101
The ``authenticate`` method takes credentials as keyword arguments. Most of
101102
the time, it'll just look like this::

0 commit comments

Comments
 (0)