deal with migrations problem
diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py
index 57025b4..e483a79 100644
--- a/planetstack/core/models/plcorebase.py
+++ b/planetstack/core/models/plcorebase.py
@@ -82,10 +82,43 @@
def get_field_diff(self, field_name):
return self.diff.get(field_name, None)
-class PlCoreBase(models.Model, DiffModelMixIn):
+class PlCoreBase(models.Model): # , DiffModelMixIn):
objects = PlCoreBaseManager()
deleted_objects = PlCoreBaseDeletionManager()
+ # ---- copy stuff from DiffModelMixin ----
+
+ # XXX Django fails miserably when trying to create initial migrations when
+ # DiffModelMixin is used. So, until we figure out what's wrong,
+ # just copied the guts of DiffModelMixIn here.
+
+ @property
+ def _dict(self):
+ return model_to_dict(self, fields=[field.name for field in
+ self._meta.fields])
+
+ @property
+ def diff(self):
+ d1 = self._initial
+ d2 = self._dict
+ diffs = [(k, (v, d2[k])) for k, v in d1.items() if v != d2[k]]
+ return dict(diffs)
+
+ @property
+ def has_changed(self):
+ return bool(self.diff)
+
+ @property
+ def changed_fields(self):
+ return self.diff.keys()
+
+ def has_field_changed(self, field_name):
+ return field_name in self.diff.keys()
+
+ def get_field_diff(self, field_name):
+ return self.diff.get(field_name, None)
+ # ---- end copy stuff from DiffModelMixin ----
+
# default values for created and updated are only there to keep evolution
# from failing.
created = models.DateTimeField(auto_now_add=True, default=timezone.now)