From 92501d8e41274d6ba4e803660c91ec6f634befaa Mon Sep 17 00:00:00 2001
From: Bastian Kleineidam <calvin@debian.org>
Date: Mon, 28 Jan 2008 13:58:32 +0100
Subject: Make models hashable
The Model instances should be hashable so that tests like
"instance in set([instance1, instance2])" actually succeed.
Signed-off-by: Bastian Kleineidam <calvin@debian.org>
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 57660dd..c52d3dd 100644
a
|
b
|
class Model(object):
|
110 | 110 | def __ne__(self, other): |
111 | 111 | return not self.__eq__(other) |
112 | 112 | |
| 113 | def __hash__ (self): |
| 114 | return hash(self._get_pk_val()) |
| 115 | |
113 | 116 | def __init__(self, *args, **kwargs): |
114 | 117 | dispatcher.send(signal=signals.pre_init, sender=self.__class__, args=args, kwargs=kwargs) |
115 | 118 | |