开发者

Problem embedding youtube video's with with django template

开发者 https://www.devze.com 2023-03-14 16:33 出处:网络
I have a django template that displays a list of objects with youtube videos: {% for obj in objs %} <h1>{{ obj.name }}</h1>

I have a django template that displays a list of objects with youtube videos:

{% for obj in objs %}
    <h1>{{ obj.name }}</h1>
    <iframe width="425" height="349" src="{{ obj.video}}" frameborder="0" allowfullscreen=""></iframe>
{开发者_如何学编程% endfor %}

obj.video is stord as a urlField. When I load the page chrome console gives me the error refused to display document because display forbidden by x-frame-options.

The problem persists if I replace {{ obj.video }} with a manually written youtube embed url such as http://youtu.be/zzfQwXEqYaI. However, if I replace it with something like www.google.com the iframes will load.


Try embedding the video like with url like:

http://www.youtube.com/embed/zzfQwXEqYaI

I guess its some kind of protection from youtube

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号