From e999c506ac3b74ad161afc5938f6bf8bd8a5256f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 11 Sep 2019 23:42:06 +0200 Subject: Serialization: add ContenType to type serialization - fix group, permission and content_type import --- ishtar_common/serializers_utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ishtar_common/serializers_utils.py') diff --git a/ishtar_common/serializers_utils.py b/ishtar_common/serializers_utils.py index 2242c349e..efa390e59 100644 --- a/ishtar_common/serializers_utils.py +++ b/ishtar_common/serializers_utils.py @@ -20,7 +20,16 @@ SERIALIZATION_VERSION = "1.0" def get_model_from_filename(filename): filename = filename.split(".")[0] # remove extension module_name, model_name = filename.split("__") - module = importlib.import_module(module_name + ".models") + if module_name == "django": + if model_name in ("Group", "Permission"): + module = importlib.import_module("django.contrib.auth.models") + elif model_name in ("ContentType", ): + module = importlib.import_module( + "django.contrib.contenttypes.models") + else: + return + else: + module = importlib.import_module(module_name + ".models") return getattr(module, model_name) -- cgit v1.2.3