mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #28742 -- Fixed AttributeError crash when assigning None to cached reverse relations.
This commit is contained in:
@@ -428,13 +428,10 @@ class ReverseOneToOneDescriptor:
|
||||
|
||||
if value is None:
|
||||
# Update the cached related instance (if any) & clear the cache.
|
||||
try:
|
||||
# Following the example above, this would be the cached
|
||||
# ``restaurant`` instance (if any).
|
||||
rel_obj = self.related.get_cached_value(instance)
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
# Following the example above, this would be the cached
|
||||
# ``restaurant`` instance (if any).
|
||||
rel_obj = self.related.get_cached_value(instance, default=None)
|
||||
if rel_obj is not None:
|
||||
# Remove the ``restaurant`` instance from the ``place``
|
||||
# instance cache.
|
||||
self.related.delete_cached_value(instance)
|
||||
|
||||
Reference in New Issue
Block a user