I need to get the file type of the uploaded file in django template. I have written a templatetag for getting file name but I need file type also.
I might be able to get the content-type of the file but I couldn't find it while debugging.
doc_list.html
{{ d.file|filename }}
{{ d.file|filetype }}
templatetags/helper.py
register = template.Library()
@register.filter
def filename(value):
return os.path.basename(value.file.name)
@register.filter
def filetype(value):
return ???