This validator works well with FileField form fields and can validate that an uploaded file has an acceptable mimetype. Place this snippet in your app's validators.py.
Requirements:
This snippet uses python-magic. To install:
pip install python-magic