From 25f4dbb9cdb91901679dbd4b54effd881ad9994c Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Thu, 11 Jul 2019 22:10:42 +0200 Subject: [PATCH] Restore single if-statement of PR #369 change --- polymorphic/models.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/polymorphic/models.py b/polymorphic/models.py index e2bb0a2..40f9ce3 100644 --- a/polymorphic/models.py +++ b/polymorphic/models.py @@ -107,13 +107,13 @@ class PolymorphicModel(six.with_metaclass(PolymorphicModelBase, models.Model)): # Protect against bad imports (dumpdata without --natural) or other # issues missing with the ContentType models. - if model is not None and not issubclass(model, self.__class__): - if self.__class__._meta.proxy_for_model is None or \ - not issubclass(model, self.__class__._meta.proxy_for_model): - - raise PolymorphicTypeInvalid("ContentType {0} for {1} #{2} does not point to a subclass!".format( - self.polymorphic_ctype_id, model, self.pk, - )) + if model is not None \ + and not issubclass(model, self.__class__) \ + and (self.__class__._meta.proxy_for_model is None \ + or not issubclass(model, self.__class__._meta.proxy_for_model)): + raise PolymorphicTypeInvalid("ContentType {0} for {1} #{2} does not point to a subclass!".format( + self.polymorphic_ctype_id, model, self.pk, + )) return model