So is there a way/reason to us presence Of validator on a File Element in a form ?
Greetings Brieuc As you can see i've commented the validator and i'm validating the file field manually in the controller .
There is a huge chance of exploiting a file upload option with malicious intent.
Improper implementation of a file upload input increases security vulnerability.
Immagine for example that you need to add the possibility to upload a PDF or Zip file in the admin, but you want to be sure your client will upload only these two filetypes and not other ones.
You might also need the same functionality in the frontend, so why not use "Model Form" and have just one validation for both applications (admin and frontend)?
Ok, it is right but visually we are showing the same messages at once. This validation must allows to show each message separately or to show them all together. it also generates a “message container” called “name”. This operation will not fail if the container doesn’t exist or it’s empty.
We could show more than one message at the same time. https://github.com/EFTEC/Validation One What’s the advantadge of this library or why we are using it: It will read the value “frm_name” from POST.
With this custom file field you can configure the maximum file size for each File Field independantly from the default behavior of Django.
You can also consider this post as a reference about "How to add a custom filefield with custom behavior to your django application".
I added a validator in order to check if the File filed is empty.
But i already check this in my controller and furthermore the validation returns always false although without the validation, the field works perfectly fine.
What if instead of return a boolean, we return an error message? But, what if the user input fails in more than one time at the same time?