diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py index 434997d6164..82b217f8295 100644 --- a/django/contrib/sessions/middleware.py +++ b/django/contrib/sessions/middleware.py @@ -37,6 +37,7 @@ class SessionWrapper(object): return self._session.get(key, default) def pop(self, key, *args): + self.modified = self.modified or key in self._session return self._session.pop(key, *args) def set_test_cookie(self): diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py index 5a28effa869..e83442123ea 100644 --- a/django/contrib/sessions/tests.py +++ b/django/contrib/sessions/tests.py @@ -5,8 +5,24 @@ Inject data into the session cache. >>> s._session_cache = {} >>> s._session_cache['some key'] = 'exists' +>>> s.accessed +False +>>> s.modified +False + +>>> s.pop('non existant key', 'does not exist') +'does not exist' +>>> s.accessed +True +>>> s.modified +False + >>> s.pop('some key') 'exists' +>>> s.accessed +True +>>> s.modified +True >>> s.pop('some key', 'does not exist') 'does not exist'