在我的django应用程序中,我显示的是这样上传的文件:
{% extends 'base.html' %}
{% block content %}
{% for i in images %}
<embed src="{{ i.document.url }}" width="1600"
height="700"
type="application/pdf"/>
<a href="{% url 'employee:delete_product_file' pk=pk %}" class="btn btn-outline-secondary" role="button" >Delete</a>
{% endfor %}
{% endblock %}
Views.py
def view_product(request,pk):
print("function called with pk ",pk)
images = Uploaded_products.objects.filter(products_connected = pk)
print("images ",images)
return render(request, "packsapp/employee/productspdf.html", {'images': images, 'pk': pk})
当我上传PDF文件时,它工作正常,但是当存在任何其他格式(如.docx或任何excel文件)时,它会提示您只需下载文件即可。
如何显示Django模板中的所有文件类型?
我假设它与type="application/pdf
答案 0 :(得分:0)
并非完全是您的要求,但是另一种方法是将文件发布到Google驱动器,然后嵌入它们。