From 158fd81ef5a5647d27eb3065063284f9ee0a3ca4 Mon Sep 17 00:00:00 2001 From: Amar <100243770+aadeina@users.noreply.github.com> Date: Tue, 3 Feb 2026 00:34:04 +0000 Subject: Fixed #36899 -- Implemented SessionBase.__bool__. --- docs/topics/http/sessions.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docs/topics/http') diff --git a/docs/topics/http/sessions.txt b/docs/topics/http/sessions.txt index 797b49ffa2..6070b3e4ef 100644 --- a/docs/topics/http/sessions.txt +++ b/docs/topics/http/sessions.txt @@ -191,6 +191,17 @@ You can edit it multiple times. Example: ``'fav_color' in request.session`` + .. method:: __bool__() + + .. versionadded:: 6.1 + + Returns the inverse of :meth:`is_empty`. This allows checking if a + session has data:: + + if request.session: + # Session has data or a key + pass + .. method:: get(key, default=None) .. method:: aget(key, default=None) -- cgit v1.3