How to Add Custom Validation on Django Form Fields

Опубликовано: 17 Май 2019
на канале: Jarad Python
8,504
98

In this video, we'll cover how to add custom validation on Django form fields.

The clean_fieldname() method is called on a form subclass – where "fieldname" is replaced with the name of the form field attribute. This method does any cleaning that is specific to that particular attribute, unrelated to the type of field that it is. This method is not passed any parameters. You will need to look up the value of the field in self.cleaned_data and remember that it will be a Python object at this point, not the original string submitted in the form (it will be in cleaned_data because the general field clean() method, above, has already cleaned the data once).

Helpful links
https://docs.djangoproject.com/en/2.2...
https://docs.djangoproject.com/en/2.2...
https://gist.github.com/michenriksen/...


Смотрите видео How to Add Custom Validation on Django Form Fields онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Jarad Python 17 Май 2019. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 8,504 раз и оно понравилось 98 посетителям.