Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 嵌入的pdf文件未在Django中显示_Python_Html_Django_Iframe_Embed - Fatal编程技术网

Python 嵌入的pdf文件未在Django中显示

Python 嵌入的pdf文件未在Django中显示,python,html,django,iframe,embed,Python,Html,Django,Iframe,Embed,我试图在django项目中使用显示照片和pdf文件,但pdf文件未显示 这就是我所做的 这是查看功能 @login_required def view_documents(request): students = Student.objects.filter(user=request.user) return render(request, 'student/view_documents.html',{'students':students}) 然后我在模板中使用标签 {% f

我试图在django项目中使用
显示照片和pdf文件,但pdf文件未显示 这就是我所做的 这是查看功能

@login_required
def view_documents(request):
    students = Student.objects.filter(user=request.user)
    return render(request, 'student/view_documents.html',{'students':students})
然后我在模板中使用标签

{% for student in students %}
#lines of code
{% endfor %}
并显示我使用的pdf文件

<embed src="{{student.adhar_card_pdf.url}}" width="800px" height="400px" type="application/pdf"/>

但它显示了某种错误,比如localhost拒绝连接 我还使用了iframe

 <iframe src="{{student.adhar_card_pdf.url}}" style="width:718px; height:700px;" frameborder="0"></iframe>

但图像在浏览器中显示时使用的代码相同,没有任何错误

<embed src="{{student.photo_jpg.url}}" width="230px" height="250px" />

为什么pdf文件不显示??请帮帮我 提前准备好。 已编辑:在控制台中它正在显示--拒绝在帧中显示“”,因为它将“X-frame-Options”设置为“deny”。

在settings.py中的
中间件
部分前面插入上述行 对于嵌入标记写入路径中的文件路径

{{student.file.get.photo_jpg.url}}
然后在Chrome或您正在使用的任何浏览器中进行硬重置


我希望它对您也适用。

打开浏览器开发工具,告诉我们您看到的确切错误。查看“网络”选项卡并检查它试图获取的url。查看您的服务器控制台并告诉我们您在那里看到了什么。在控制台中,它显示:拒绝在帧中显示“”,因为它将“X-frame-Options”设置为“deny”。
{{student.file.get.photo_jpg.url}}