From 5f2576ec6ca75a5e6f31b901382cf75885d0f383 Mon Sep 17 00:00:00 2001 From: Emilie Date: Tue, 26 Dec 2017 16:12:24 +0100 Subject: [PATCH] Check if 'descendants' list has values --- modeltranslation/translator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modeltranslation/translator.py b/modeltranslation/translator.py index ebe93cc..3a9a297 100644 --- a/modeltranslation/translator.py +++ b/modeltranslation/translator.py @@ -466,9 +466,10 @@ class Translator(object): else: descendants = [d.__name__ for d in self._registry.keys() if issubclass(d, model) and d != model] - raise DescendantRegistered( - 'Model "%s" cannot be registered after its subclass' - ' "%s"' % (model.__name__, descendants[0])) + if descendants: + raise DescendantRegistered( + 'Model "%s" cannot be registered after its subclass' + ' "%s"' % (model.__name__, descendants[0])) # Find inherited fields and create options instance for the model. opts = self._get_options_for_model(model, opts_class, **options)