Python django.forms() Examples
The following are 1
code examples of django.forms().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django
, or try the search function
.
Example #1
Source File: utils.py From Dailyfresh-B2C with Apache License 2.0 | 6 votes |
def raw_validation(error): """ Deconstruct a django.forms.ValidationError into a primitive structure eg, plain dicts and lists. """ if isinstance(error, ValidationError): if hasattr(error, 'error_dict'): error = error.error_dict elif not hasattr(error, 'message'): error = error.error_list else: error = error.message if isinstance(error, dict): return {key: raw_validation(value) for key, value in error.items()} elif isinstance(error, list): return [raw_validation(value) for value in error] else: return error