From 90dd281f7c34260a3cc7956a0d2be319d4dc9f26 Mon Sep 17 00:00:00 2001 From: reverend Date: Sun, 29 Nov 2020 19:22:38 +0100 Subject: [PATCH] Common functionalities --- django_lostplaces/lostplaces/common.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 django_lostplaces/lostplaces/common.py diff --git a/django_lostplaces/lostplaces/common.py b/django_lostplaces/lostplaces/common.py new file mode 100644 index 0000000..1b438f9 --- /dev/null +++ b/django_lostplaces/lostplaces/common.py @@ -0,0 +1,11 @@ +def get_all_subclasses(cls): + ''' + Gets all subclasses recursively, does not contain + abstract classes + ''' + subclass_list = [] + for subclass in cls.__subclasses__(): + if not subclass._meta.abstract: + subclass_list.append(subclass) + subclass_list += get_all_subclasses(subclass) + return subclass_list \ No newline at end of file