Ticket #11192: ModelForms_checks.patch

File ModelForms_checks.patch, 785 bytes (added by Anton Kolechkin, 15 years ago)
  • models.py

     
    215215        opts = self._meta
    216216        if instance is None:
    217217            # if we didn't get an instance, instantiate a new one
     218           
     219            # we should to check if model is in opts before creating instance
     220            if not hasattr(opts, 'model') or opts.model is None:
     221                raise ValueError('model attribute is not set in ModelForm or None')
     222
     223            # and need to check if instance is callable
     224            if not callable(opts.model):
     225                raise TypeError('model should be callable')
     226
    218227            self.instance = opts.model()
    219228            object_data = {}
    220229        else:
Back to Top