summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorGert Burger <gertburger@gmail.com>2020-08-07 10:02:29 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-12 12:43:42 +0200
commit94ea79be137f3cb30949bf82198e96e094f2650d (patch)
treed268c3a757e7584b96f9d6235eb0ee762b766e12 /django
parent63300f7e686c2c452763cb512df9abf7734fd588 (diff)
Fixed #31863 -- Prevented mutating model state by copies of model instances.
Regression in bfb746f983aa741afa3709794e70f1e0ab6040b5.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/base.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 3792ffb90e..7c7bd2d7ee 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -546,7 +546,10 @@ class Model(metaclass=ModelBase):
def __getstate__(self):
"""Hook to allow choosing the attributes to pickle."""
- return self.__dict__
+ state = self.__dict__.copy()
+ state['_state'] = copy.copy(state['_state'])
+ state['_state'].fields_cache = state['_state'].fields_cache.copy()
+ return state
def __setstate__(self, state):
pickled_version = state.get(DJANGO_VERSION_PICKLE_KEY)