In this video, we'll look at Django model field validators, such as the MinValueValidator, MaxValueValidator, as well as writing our own custom validator functions.
We'll also briefly look at how ModelForms hook into models, and use the validators that are defined on fields on the model that are included in the ModelForm.
Finally, we'll see how ModelForm subclasses pull choices that are defined on a model field into the form as options in a select field.
To see more on using Validators, you can also check this video where we validate the FILE EXTENSION of an uploaded file using Django's FileExtensionValidator:
https://www.youtube.com/watch?v=UcUm82jWeKc
๐ ๐๐ต๐ฎ๐ฝ๐๐ฒ๐ฟ๐:
00:00 Intro
01:56 Using Django MinValueValidator & MaxValueValidator
06:09 Creating a ModelForm that uses model field validators
13:21 Writing custom validator functions
17:17 Using Choices in Django forms
โ๏ธ ๐๐๐ ๐บ๐ฒ ๐ฎ ๐ฐ๐ผ๐ณ๐ณ๐ฒ๐ฒ:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes
โถ๏ธ Full Playlist:
https://www.youtube.com/playlist?list=PL-2EBeDYMIbQXKsyNweppuFptuogJe2L-
๐ฆ๐ผ๐ฐ๐ถ๐ฎ๐น ๐ ๐ฒ๐ฑ๐ถ๐ฎ:
๐ Blog: https://bugbytes.io/posts/
๐พ Github: https://github.com/bugbytes-io/
๐ฆ Twitter: https://twitter.com/bugbytesio
๐ ๐๐๐ฟ๐๐ต๐ฒ๐ฟ ๐ฟ๐ฒ๐ฎ๐ฑ๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐ถ๐ป๐ณ๐ผ๐ฟ๐บ๐ฎ๐๐ถ๐ผ๐ป:
Django Validators: https://docs.djangoproject.com/en/4.2/ref/validators/
ModelForms: https://docs.djangoproject.com/en/4.2/topics/forms/modelforms/
#python #django #webdevelopment #database #sql