Задать вопрос

Тел: +7 965 3737 888

556

Просмотров

0

Ответов

Validation for 'unique' and 'unique_together' constraints (different version)

This is a slightly different and extendend version of this snippet:

http://www.djangosnippets.org/snippets/260/

Unique constraints for single fields are validated in a clean_FIELD, instead of globally in the form's clean() method, so that the error messages are correctly assigned to each field.

Additionally, you can specify mappings for unique_together constraints to assign those error messages to a specific field as well (instead of having them in non_field_errors(), where they would normally be.

Вопрос полезен? Да0/Нет0
file_3357.py(10.8Кб)
None