Get model class

def get_model_class(self):
        """Get model class"""
        if getattr(self, 'model', None):
            return self.model
        elif getattr(self, 'object', None):
            return self.object.__class__
        elif 'app' in self.kwargs and 'model' in self.kwargs:
            return apps.get_model(self.kwargs.get('app'), self.kwargs.get('model'))
        elif hasattr(self, 'get_queryset'):
            return self.get_queryset().model
        else:
            return None