Daniel Nill
Daniel Nill

Reputation: 5747

Problem embedding youtube video's with with django template

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.

Upvotes: 4

Views: 4316

Answers (1)

Tudor Constantin
Tudor Constantin

Reputation: 26861

Try embedding the video like with url like:

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

I guess its some kind of protection from youtube

Upvotes: 4

Related Questions