summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-03-25 11:18:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-03-25 11:18:52 +0100
commitccaee8c26350bd00adfb771d6f35c663ef115b5a (patch)
tree4d99926fb277114246a27e9cd343d2d727c284aa
parenta252dd421144879060fbf08981b49f797a9a6653 (diff)
downloadIshtar-ccaee8c26350bd00adfb771d6f35c663ef115b5a.tar.bz2
Ishtar-ccaee8c26350bd00adfb771d6f35c663ef115b5a.zip
Fix item creation when no last_modified is set
-rw-r--r--CHANGES.md7
-rw-r--r--ishtar_common/models_common.py5
-rw-r--r--ishtar_common/version.py4
3 files changed, 12 insertions, 4 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 9fe4c0bf1..f8c7afbcb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,6 +1,13 @@
Ishtar changelog
================
+v3.1.54 - 2022-03-25
+--------------------
+
+### Bugs ###
+
+- fix item creation when no last_modified is set
+
v3.1.53 - 2022-03-24
--------------------
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index dbca97367..48c1e9dc1 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -1303,7 +1303,7 @@ class BaseHistorizedItem(
blank=True,
null=True,
)
- last_modified = models.DateTimeField()
+ last_modified = models.DateTimeField(blank=True, default=datetime.datetime.now)
history_m2m = JSONField(default={}, blank=True)
need_update = models.BooleanField(verbose_name=_("Need update"), default=False)
locked = models.BooleanField(
@@ -1552,7 +1552,8 @@ class BaseHistorizedItem(
def save(self, *args, **kwargs):
created = not self.pk
- if not getattr(self, "_no_last_modified_update", False):
+ if not getattr(self, "_no_last_modified_update", False) \
+ or not self.last_modified:
self.last_modified = datetime.datetime.now()
if not getattr(self, "skip_history_when_saving", False):
assert hasattr(self, "history_modifier")
diff --git a/ishtar_common/version.py b/ishtar_common/version.py
index 96e9aba64..55ccb08ca 100644
--- a/ishtar_common/version.py
+++ b/ishtar_common/version.py
@@ -1,5 +1,5 @@
-# 3.1.53
-VERSION = (3, 1, 53)
+# 3.1.54
+VERSION = (3, 1, 54)
def get_version():