Re: Model Validation with Exception Handling

2012-09-13 Thread Jani Tiainen
Hi, I'm using following piece of code with ExtJS: def extjs_validate_instance(instance): """Validate given Django model instance. Return ExtJS formatted error response. """ try: instance.full_clean() # Validate except ValidationError, e: opts = instance._meta

Re: Model Validation with Exception Handling

2012-09-12 Thread Kurtis Mullins
Just a quick example of a field that can have two completely different error types but both throw a ValidationError while running full_clean(). Let's say my Model includes an email address. The email address must be unique. It could either fail because 1. It's not Unique (or) 2. It's an invalid em

Model Validation with Exception Handling

2012-09-12 Thread Kurtis
Hey Guys, Do you have any suggestions on a good way to grab error types during Model Validation? I'm not using Forms or HTML. First, here's a simplified snippet showing my current format for Model Data Validation. my_object = MyModel(**data_dict) try: my_object.full_clean() my_object.sa