'Ensures the doc_file is valid.'

def clean_doc_file(self):

    doc_file = self.cleaned_data.get('doc_file')
    if (doc_file and (not (os.path.splitext(doc_file.name)[1].lower()[1:] in settings.ALLOWED_DOCUMENT_TYPES))):
        raise forms.ValidationError(_('This    file    type    is    not    allowed'))
    return doc_file
