From 22e016ff6c18a35a450519b94de63033f83e6b4f Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Thu, 28 Feb 2008 21:24:51 +0000 Subject: gis: Merged revisions 7105-7168 via svnmerge from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7176 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'django/db/models/base.py') diff --git a/django/db/models/base.py b/django/db/models/base.py index 60bf021e4e..d96c93fb0d 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -41,7 +41,9 @@ class ModelBase(type): # Build complete list of parents for base in parents: - if base is not Model: + # Things without _meta aren't functional models, so they're + # uninteresting parents. + if hasattr(base, '_meta'): new_class._meta.parents.append(base) new_class._meta.parents.extend(base._meta.parents) @@ -133,13 +135,16 @@ 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) # There is a rather weird disparity here; if kwargs, it's set, then args # overrides it. It should be one or the other; don't duplicate the work # The reason for the kwargs check is that standard iterator passes in by - # args, and nstantiation for iteration is 33% faster. + # args, and instantiation for iteration is 33% faster. args_len = len(args) if args_len > len(self._meta.fields): # Daft, but matches old exception sans the err msg. -- cgit v1.3