| 248 | |
| 249 | def error_list(fields, error_dict): |
| 250 | errors = [] |
| 251 | for err_field_name, err_messages in error_dict.items(): |
| 252 | error = {} |
| 253 | for field in fields: |
| 254 | if field.name == err_field_name: |
| 255 | error['verbose_name'] = capfirst(field.verbose_name) |
| 256 | error['messages'] = err_messages |
| 257 | elif isinstance(field, models.fields.DateTimeField): |
| 258 | parts = err_field_name.split("_") |
| 259 | if parts[-1] in ["date", "time"] and '_'.join(parts[:-1]) == field.name: |
| 260 | error['verbose_name'] = capfirst("%s (%s)" % (field.verbose_name, parts[-1])) |
| 261 | error['messages'] = err_messages |
| 262 | if not error: |
| 263 | raise RuntimeError, "verbose field name error not found for: %s" % err_field_name |
| 264 | errors.append(error) |
| 265 | return {'error_list': errors} |
| 266 | error_list = register.inclusion_tag('admin/error_list.html')(error_list) |