1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Refs #21608 -- Fixed incorrect cache key in cache session backend's save().

The bug was introduced commit 3389c5ea22.
This commit is contained in:
Jon Dufresne 2016-04-03 15:09:10 -07:00 committed by Tim Graham
parent fdf5cd3429
commit 5faf745999
2 changed files with 7 additions and 1 deletions

View File

@ -57,7 +57,7 @@ class SessionStore(SessionBase):
return self.create()
if must_create:
func = self._cache.add
elif self._cache.get(self.session_key) is not None:
elif self._cache.get(self.cache_key) is not None:
func = self._cache.set
else:
raise UpdateError

View File

@ -613,6 +613,12 @@ class CacheSessionTests(SessionTestsMixin, unittest.TestCase):
self.assertEqual(caches['default'].get(self.session.cache_key), None)
self.assertNotEqual(caches['sessions'].get(self.session.cache_key), None)
def test_create_and_save(self):
self.session = self.backend()
self.session.create()
self.session.save()
self.assertIsNotNone(caches['default'].get(self.session.cache_key))
class SessionMiddlewareTests(TestCase):