Commits

jgsogo committed 6dcc5e3 Draft

avoid plain except

  • Participants
  • Parent commits 48e76bd

Comments (0)

Files changed (1)

model_utils/managers.py

 from django.db.models.fields.related import OneToOneField
 from django.db.models.manager import Manager
 from django.db.models.query import QuerySet
+from django.core.exceptions import ObjectDoesNotExist
 
 
 class InheritanceQuerySet(QuerySet):
                 def get_attr(obj, s):
                     try:
                         return getattr(obj,s)
-                    except:
+                    except ObjectDoesNotExist:
                         return None
                 sub_obj = [getattr(obj, s) for s in self.subclasses if get_attr(obj, s)] or [obj]
                 sub_obj = sub_obj[0]