Описанный вами метод (повышение ValidationError
из Form.clean
) является официальным способом проверки нескольких полей .
. Вы можете получить доступ к загруженным файлам из self.files
по методу clean
.От django/forms/forms.py
:
class BaseForm(StrAndUnicode):
# This is the main implementation of all the Form logic. Note that this
# class is different than Form. See the comments by the Form class for more
# information. Any improvements to the form API should be made to *this*
# class, not to the Form class.
def __init__(self, data=None, files=None, ...):
self.is_bound = data is not None or files is not None
self.data = data or {}
self.files = files or {}
...