Closed
Description
Checklist
- I have verified that that issue exists against the
master
branch of Django REST framework. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- This is not a usage question. (Those should be directed to the discussion group instead.)
- This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
- I have reduced the issue to the simplest possible case.
- I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)
Descriptions
In this release[https://docs.djangoproject.com/en/1.11/releases/1.11/#models] Django added default validator for ImageField.
This validation steps is ignored in DRF
Steps to reproduce
- Take png image and change extension .txt
- Upload
Expected behavior
ValidationError: [u"File extension 'txt' is not allowed. Allowed extensions are: 'ppm, grib, im, rgba, rgb, jpx, h5, jpe, jpf, jpg, fli, jpc, sgi, gbr, pcx, mpeg, jpeg, ps, flc, tif, hdf, icns, gif, palm, mpg, fits, pgm, mic, pxr, fit, xbm, eps, emf, jp2, dcx, webp, bmp, bw, pbm, j2c, psd, pcd, ras, j2k, mpo, cur, fpx, ftu, png, msp, iim, wmf, jfif, tga, bufr, ico, ftc, xpm, pdf, dds, tiff'."]
Actual behavior
It's valid.
Suggestion
Add to ImageFIeld something like this:
if hasattr(self._DjangoImageField, 'default_validators'):
self.default_validators.extend(self._DjangoImageField.default_validators)
Metadata
Metadata
Assignees
Labels
No labels