diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-06-08 17:20:31 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-06-08 17:20:31 +0200 |
commit | 3091cfde5a536750bfeedcbe12a8891f898eb159 (patch) | |
tree | a97c42b07c2f79dbb6c2926b64d9ad1a6e2aabc8 | |
parent | 8e921087fa389d878c918db06190d91a494845b5 (diff) | |
download | Ishtar-3091cfde5a536750bfeedcbe12a8891f898eb159.tar.bz2 Ishtar-3091cfde5a536750bfeedcbe12a8891f898eb159.zip |
ID: allow use "data" field to generate ID
-rw-r--r-- | CHANGES.md | 9 | ||||
-rw-r--r-- | ishtar_common/utils.py | 14 | ||||
-rw-r--r-- | ishtar_common/version.py | 4 |
3 files changed, 20 insertions, 7 deletions
diff --git a/CHANGES.md b/CHANGES.md index 8dfeb312c..e9dda6ecc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,18 @@ --- title: Ishtar changelog -date: 2022-06-02 +date: 2022-06-08 --- Ishtar changelog ================ +v3.1.74 - 2022-06-08 +-------------------- + +### Features ### + +- ID: allow use "data" field to generate ID + v3.1.73 - 2022-06-07 -------------------- diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index bad6399df..5bd5f4ec5 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -1943,10 +1943,16 @@ def _update_gen_id_dct(item, dct, initial_key, fkey=None, filters=None): return obj = item for k in fkey.split("__"): - try: - obj = getattr(obj, k) - except (ObjectDoesNotExist, AttributeError): - obj = None + if isinstance(obj, dict): + if k not in obj: + obj = None + break + obj = obj[k] + else: + try: + obj = getattr(obj, k) + except (ObjectDoesNotExist, AttributeError): + obj = None if hasattr(obj, "all") and hasattr(obj, "count"): # query manager if not obj.count(): break diff --git a/ishtar_common/version.py b/ishtar_common/version.py index 276033fb0..89fcb4e7d 100644 --- a/ishtar_common/version.py +++ b/ishtar_common/version.py @@ -1,5 +1,5 @@ -# 3.1.73 -VERSION = (3, 1, 73) +# 3.1.74 +VERSION = (3, 1, 74) def get_version(): |