Skip to content

Instantly share code, notes, and snippets.

@mazlum
Last active December 30, 2015 20:16
Show Gist options
  • Select an option

  • Save mazlum/e9ba24145487812143a3 to your computer and use it in GitHub Desktop.

Select an option

Save mazlum/e9ba24145487812143a3 to your computer and use it in GitHub Desktop.
File extension validation validator for Django framework.
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