Solution 1 :

I had the same problem. If you can navigate to the project.publications_pdf.url in your browser and your pdf is displayed, then it is likely to be an issue when rendering the frame, add



If when you navigate to project.publications_pdf.url in your browser you also do not see the pdf then your pdf is not being served from your media folder. Make sure in your main you are able to serve your media files, i.e. include,

from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
    your current paths,
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Problem :

I have stored a pdf in my media folder and would like to embed it in my template. It says ‘ is blocked’ and ‘ refused to connect’.

My HTML code:

<embed src="{{ project.publications_pdf.url }}" type="application/pdf" height="700px" width="500px">

The url is stored in the Project model as publications_pdf.


Comment posted by……