summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/core/meta/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/core/meta/__init__.py b/django/core/meta/__init__.py
index 1d58201b28..3aaaad576b 100644
--- a/django/core/meta/__init__.py
+++ b/django/core/meta/__init__.py
@@ -729,6 +729,7 @@ class ModelBase(type):
# Create the default class methods.
attrs['__init__'] = curry(method_init, opts)
attrs['__eq__'] = curry(method_eq, opts)
+ attrs['__ne__'] = curry(method_ne, opts)
attrs['save'] = curry(method_save, opts)
attrs['save'].alters_data = True
attrs['delete'] = curry(method_delete, opts)
@@ -978,6 +979,9 @@ def method_init(opts, self, *args, **kwargs):
def method_eq(opts, self, other):
return isinstance(other, self.__class__) and getattr(self, opts.pk.attname) == getattr(other, opts.pk.attname)
+def method_ne(opts, self, other):
+ return not method_eq(opts, self, other)
+
def method_save(opts, self):
# Run any pre-save hooks.
if hasattr(self, '_pre_save'):