title: Using Django to show YouTube videos in templates
body: <p>I'm attempting to store a list of YouTube links in a model then passing it as a list to a template where it's rendered using YouTube's embed code. Everything seems to be working fine, the variables are passed properly except the videos don't show up. The YouTube iframe code is just blank whereas a copy/pasted of YouTube embed code displays just fine.</p>
  
  <p>The code in the Model:</p>
  
  <pre><code>from django.db import models
  
  class Video(models.Model):
      link = models.URLField()
  
      def __str__(self):
          return self.link                            
  </code></pre>
  
  <p>The code in the View:</p>
  
  <pre><code>def index(request):
      full_list = Video.objects.all()
      return render_to_response('index.html', {'full_list': full_list})
  </code></pre>
  
  <p>The code in the Template:</p>
  
  <pre><code>&lt;h1&gt;YouTube list&lt;/h1&gt;
  {% if full_list %}
      &lt;ul&gt;
      {% for video in full_list %}
          &lt;li&gt;
  &lt;!-- link passed to embed code, this shows up as blank --&gt;
  &lt;iframe width="560" height="345" src="{{ video.link }}?rel=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
  
  &lt;!-- YouTube embed link copy/pasted as is --&gt;
  &lt;iframe width="560" height="345" src="http://www.youtube.com/embed/vLmNvYTTWXM?rel=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
          &lt;/li&gt;
      {% endfor %}
      &lt;/ul&gt;
  {% else %}
      &lt;p&gt;No videos available&lt;/p&gt;
  {% endif %}
  </code></pre>
  
  <p>
      </p>
  
  <p>Screenshot of the browser: <a href="https://img.skitch.com/20110910-t78bm288mxh6nmyjmcbxyjr37n.png" rel="nofollow">https://img.skitch.com/20110910-t78bm288mxh6nmyjmcbxyjr37n.png</a></p>
  
  <p>I'm guessing that the templates are rendered first and the variable is added second hence YouTube's server is not even called. Is this a correct assumption and if so how do I go about fixing it?</p>