Django cannot display a PDF inline on a web page using <embed> or <object> or <iframe> tags [duplicate]
I am trying to embed a PDF into a web page in Django. This is the message I see in the console:
Refused to display 'http://127.0.0.1:8000/' in a frame because it set 'X-Frame-Options' to 'deny'.
Here is the function definition in my python file:
from django.http import HttpResponse
from django.views.decorators.clickjacking import xframe_options_exempt
from django.template.loader import render_to_string
...
@login_required
@xframe_options_exempt
def resource_entity_screen(request,pk):
...
rendered = render_to_string('classroom/resourcecenter/resource_entity_display.html', \
{'src' : url_src, \
'embed_pdf' : embed_pdf, \
'embed_video' : embed_video, \
'embed_audio' : embed_audio, \
'embed_image' : embed_image, \
'obj_type' : obj_type, \
'image_info' : image_info})
return HttpResponse(rendered)
I included this code instead of a straight render because I read in another post that the decorator only works with HttpResponse. However even with this code I am still getting the message shown above (in the console). I did clear my cache and do a reload, and also tried Ctrl-Shift R as well. No change.
Can anyone tell me what I am missing? Is there something additional needed in settings.py? I have not tried deploying this to a testing server on the web to see if the issue is just with my local testing environment.