Fixed exception in exception cases

Fix a bug triggered when self.model is None : 

"AttributeError: 'NoneType' object has no attribute 'DoesNotExist'"