Tag: Handle error form.save() with model validation

Handle error form.save() with model validation

Handle error form.save() with model validation

Here is a quick snippet to avoid form.save() error because model validation : 12345678# handle form save with model validationerror # http://stackoverflow.com/questions/8771029/django-raise-a-validation-error-in-a-models-save-method try:     form.save() except ValidationError, e:     form._errors = {}     for _, v in e.message_dict.items():         form._errors.setdefault(NON_FIELD_ERRORS, []).extend(v)