In this video, we will look at how to restrict the types of files that can be uploaded by users in our Django applications.
We will see three methods on how to restrict this data:
* Using file input's 'accept' parameter
* Using Django's FileExtensionValidator
* Using python-magic to verify the contents of the file match the extension.
We'll also see how to write a custom validator in Django and add multiple validators to a single Model field.
???? ????????????????????????????????:
00:00 Intro
02:27 File Input accept attribute
06:03 Adding Django FileExtensionValidator to model FileField
10:09 Using python-magic in Django Validator to check file content
☕️ ???????????? ???????? ???? ????????????????????????:
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-2EBeDYMIbQpw0N1BmAi9-acwhpxEfoo
???????????????????????? ????????????????????:
???? Blog: https://bugbytes.io/posts/
???? Github: https://github.com/bugbytes-io/
???? Twitter: https://twitter.com/bugbytesio
???? ???????????????????????????? ???????????????????????????? ???????????? ????????????????????????????????????????????:
File Input: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
Accept Attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept
Django FileExtensionValidator: https://docs.djangoproject.com/en/4.1/ref/validators/#fileextensionvalidator
Python-magic: https://pypi.org/project/python-magic/
#python #django #mediafile