'Check the submitted file for its MIME type in case the provided
MIME type is missing or is the default MIME type as given in the
model field definition.
That allows overriding the MIME type via the admin UI.'

def clean(self):

    cleaned_data = super(AttachmentRevisionForm, self).clean()
    nulls = (EMPTY_VALUES + (AttachmentRevision.DEFAULT_MIME_TYPE,))
    submitted_mime_type = cleaned_data.get('mime_type')
    if (submitted_mime_type in nulls):
        self.mime_type = self.mime_type_from_file(cleaned_data['file'])
        allowed_mime_types = config.WIKI_ATTACHMENT_ALLOWED_TYPES.split()
        if (self.mime_type not in allowed_mime_types):
            raise forms.ValidationError(MIME_TYPE_INVALID, code='invalid')
    return cleaned_data
