If you are looking for a safe way to validate your files, the file validator library will do this for you, this library also supports Django.With this library you can validate files based on extension, size, mimes and magic numbers
-
File validation using the filetype library
-
File validation using the python-magic library
-
File validation using the mimetypes library
-
File validation using the puremagic library
-
File validation with Size
-
Supporting for all mimes
-
File validation simultaneously with all four libraries
You can access it through the link below