There are probably some existing implementations we could borrow from, for
example:
https://djangosnippets.org/snippets/977/
--
Ticket URL: <https://code.djangoproject.com/ticket/21548>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => jfilipe
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:1>
Comment (by jfilipe):
I have a work in progress PR here:
https://github.com/jfilipe/django/pull/2
Wanted to get some feedback on the approach before I added some docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:3>
* needs_better_patch: 0 => 1
* needs_docs: 0 => 1
Comment:
Hi, I left a comment for improvement on the PR, although it's better to
open a PR against Django itself instead of your fork.
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:4>
Comment (by anubhav9042):
The patch looks good but the validator must be like others as Tim
suggested on your PR.
Also adding it to `ImageField` by default sounds good. I hope we can fix
#18543 with it.
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:5>
* cc: anubhav9042@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:6>
* cc: berker.peksag@… (added)
* needs_better_patch: 1 => 0
* owner: jfilipe => berkerpeksag
* needs_docs: 1 => 0
Comment:
Pull request: https://github.com/django/django/pull/6343
Changes:
* Added two validators: FileExtensionValidator and validate_image_file
(this one uses FileExtensionValidator with default values from
PIL.Image.EXTENSION).
* Added validate_image_file to ImageField as a default validator.
* Added tests for FileExtensionValidator, model and form validations.
* Added documentation and release notes. I probably need to add some note
for ImageField docs too.
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:7>
* needs_better_patch: 0 => 1
Comment:
Left some comments for improvement.
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:8>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"12b4280444b58c94197255655e284e4103fe00a9" 12b4280]:
{{{
#!CommitTicketReference repository=""
revision="12b4280444b58c94197255655e284e4103fe00a9"
Fixed #21548 -- Added FileExtensionValidator and
validate_image_file_extension.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:10>
Comment (by Baptiste Mispelon <bmispelon@…>):
In [changeset:"a9215b7c36bff232bcc9416309726290dc74a9e8" a9215b7c]:
{{{
#!CommitTicketReference repository=""
revision="a9215b7c36bff232bcc9416309726290dc74a9e8"
Refs #21548 -- Skipped tests that rely on pillow when it's not installed
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21548#comment:11>