From 804bd403838dbd01154f8f477b0ebf2045e7b4b5 Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Tue, 24 Jan 2012 07:42:38 +0000 Subject: [PATCH] Fixed #17506 -- Did a minor optimization in the sessions' database backend. Thanks to FunkyBob for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17390 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/sessions/backends/db.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/django/contrib/sessions/backends/db.py b/django/contrib/sessions/backends/db.py index 219d97d3684..3dd0d9516c7 100644 --- a/django/contrib/sessions/backends/db.py +++ b/django/contrib/sessions/backends/db.py @@ -24,11 +24,7 @@ class SessionStore(SessionBase): return {} def exists(self, session_key): - try: - Session.objects.get(session_key=session_key) - except Session.DoesNotExist: - return False - return True + return Session.objects.filter(session_key=session_key).exists() def create(self): while True: