MENU

Fun & Interesting

Django ORM - Model Field Validators / Writing Custom Validators / ModelForms

BugBytes 13,043 2 years ago
Video Not Working? Fix It Now

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

Comment