mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed bad comparison logic introduced in d97bf2e9c8.
Refs #21765. Thanks to kezabelle for the quick report and to onjin for providing the patch.
This commit is contained in:
@@ -102,7 +102,15 @@ class BaseContext(object):
|
||||
Compares two contexts by comparing theirs 'dicts' attributes.
|
||||
"""
|
||||
if isinstance(other, BaseContext):
|
||||
return self.dicts[-1] == other.dicts[-1]
|
||||
# because dictionaries can be put in different order
|
||||
# we have to flatten them like in templates
|
||||
def flatten(dicts):
|
||||
flat = {}
|
||||
for d in dicts:
|
||||
flat.update(d)
|
||||
return flat
|
||||
|
||||
return flatten(self.dicts) == flatten(other.dicts)
|
||||
|
||||
# if it's not comparable return false
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user