Last active
December 30, 2015 20:16
-
-
Save mazlum/e9ba24145487812143a3 to your computer and use it in GitHub Desktop.
File extension validation validator for Django framework.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.exceptions import ValidationError | |
| import os | |
| def validate_file_extension(value): | |
| if not os.path.splitext(str(value))[1] in [".pdf"]: | |
| raise ValidationError("Your file must be a pdf.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment