From 9506fb493ebdf22674f7fee54712bbd5890d55c0 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 9 Apr 2019 01:26:27 +0200 Subject: Importers: fix default management - allow arbitrary values - allow values directly related to the main model of the import - add a "get_default" in attribute configuration in order to force use of default settings --- ishtar_common/data_importer.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ishtar_common/data_importer.py') diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index d44a19319..baf943068 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1574,6 +1574,9 @@ class Importer(object): if attribute == 'data': # json field # no need to do anything return + if attribute == 'get_default': + # force evaluation of default value for this field + return try: field_object = cls._meta.get_field(attribute) except FieldDoesNotExist: @@ -1720,6 +1723,11 @@ class Importer(object): defaults[k] = dct.pop(k) else: dct.pop(k) + if "get_default" in dct and dct["get_default"]: + dct.pop("get_default") + new_dct = defaults.copy() + new_dct.update(dct) + dct = new_dct obj = None if self.simulate: -- cgit v1.2.3