diff options
| author | aspalding <aspalding@procuredhealth.com> | 2018-10-16 10:01:31 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-10-17 11:17:23 -0400 |
| commit | 834c4ec8e4cfc43acf0525e0a4d8c914534f6afd (patch) | |
| tree | eaa94ec0b3a2db6d1a251e4f5338f5b4a2b153f2 /django/utils/hashable.py | |
| parent | 6752c2756eb9be28a37021d664b805ec169369d6 (diff) | |
Moved make_hashable() to django.utils and added tests.
Diffstat (limited to 'django/utils/hashable.py')
| -rw-r--r-- | django/utils/hashable.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/utils/hashable.py b/django/utils/hashable.py new file mode 100644 index 0000000000..859ea8073e --- /dev/null +++ b/django/utils/hashable.py @@ -0,0 +1,9 @@ +def make_hashable(value): + if isinstance(value, list): + return tuple(map(make_hashable, value)) + if isinstance(value, dict): + return tuple([ + (key, make_hashable(nested_value)) + for key, nested_value in value.items() + ]) + return value |
