mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #21765 -- Added support for comparing Context instances
This commit is contained in:
committed by
Baptiste Mispelon
parent
985ae732b2
commit
d97bf2e9c8
@@ -97,6 +97,16 @@ class BaseContext(object):
|
||||
new_context._reset_dicts(values)
|
||||
return new_context
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Compares two contexts by comparing theirs 'dicts' attributes.
|
||||
"""
|
||||
if isinstance(other, BaseContext):
|
||||
return self.dicts[-1] == other.dicts[-1]
|
||||
|
||||
# if it's not comparable return false
|
||||
return False
|
||||
|
||||
|
||||
class Context(BaseContext):
|
||||
"A stack container for variable context"
|
||||
|
||||
Reference in New Issue
Block a user