Ticket #5101: validate-on-save.diff
File validate-on-save.diff, 669 bytes (added by , 17 years ago) |
---|
-
django/db/models/base.py
a b class Model(object): 282 282 error_dict[f.name] = errors 283 283 return error_dict 284 284 285 def validate_on_save(self): 286 """ 287 perform validation before saving 288 """ 289 errors = self.validate() 290 if len(errors): 291 from django.core import validators 292 raise validators.ValidationError (errors) 293 self.save() 294 285 295 def _collect_sub_objects(self, seen_objs): 286 296 """ 287 297 Recursively populates seen_objs with all objects related to this object.