From 343fa35a2cd4bb22457eb9031fa23c751c13f09d Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 19 Feb 2008 01:59:34 +0000 Subject: Fixed #2936, #6500 -- Added a __hash__() method to Models (since we implement our own __eq__ method). git-svn-id: http://code.djangoproject.com/svn/django/trunk@7132 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'django/db') diff --git a/django/db/models/base.py b/django/db/models/base.py index 5aa3158fee..4f034bcf8b 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -135,6 +135,9 @@ class Model(object): def __ne__(self, other): return not self.__eq__(other) + def __hash__(self): + return hash(self._get_pk_val()) + def __init__(self, *args, **kwargs): dispatcher.send(signal=signals.pre_init, sender=self.__class__, args=args, kwargs=kwargs) -- cgit v1.3