summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-03-22 13:10:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-04-16 16:43:03 +0200
commit13d4acddf63858e59c798837cf4c1f2d29945dd7 (patch)
tree8098f0883d836d54829ddcbf8a092592ffaa97bb /ishtar_common/utils.py
parentaa4b31a9638041b7ea849528f6fff45734d68ecf (diff)
downloadIshtar-13d4acddf63858e59c798837cf4c1f2d29945dd7.tar.bz2
Ishtar-13d4acddf63858e59c798837cf4c1f2d29945dd7.zip
✨ Debug mode for imports
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py
index 08e7a49b4..c88342782 100644
--- a/ishtar_common/utils.py
+++ b/ishtar_common/utils.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2013-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+import json
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -2557,6 +2558,18 @@ def human_date(value):
return value.strftime(settings.DATE_FORMAT)
+class StrJSONEncoder(json.JSONEncoder):
+ def default(self, o):
+ try:
+ return super().default(o)
+ except TypeError:
+ s = f"<{o.__class__.__name__}> "
+ if hasattr(o, "pk"):
+ s += f"[{o.pk}] "
+ s += str(o)
+ return s
+
+
class IshtarFileSystemStorage(FileSystemStorage):
def exists(self, name):
path_name = self.path(name)