Overriding <head> tag within Django template
<p>I have a Django application where users upload videos (played back via html5 <code>video</code> tag). To handle edge cases where a user is unable to playback the video, I give them the option to download it.</p>

<p>For this, I'm writing JS that ensures a "download" button appears whenever a <code>src</code> isn't loading. Here take a look: <a href="http://plnkr.co/edit/o8YFZNaEhpJMg4YPhZCO?p=preview" rel="nofollow">http://plnkr.co/edit/o8YFZNaEhpJMg4YPhZCO?p=preview</a></p>

<p>The problem is that my JS resides within <code>&lt;head&gt;&lt;/head&gt;</code> and it needs to be able to access all videos I'm going to show on page. </p>

<p>Normally, I pass video objects as an <code>object_list</code> that I then iterate through (generated through a paginated <code>ListView</code>). But all this happens in the <code>body</code> of template. </p>

<p>How can I get access to <code>context[object_list]</code> within <code>&lt;head</code>> so that the JS snippet I've shared can utilize the sources (I'm already inheriting <code>&lt;head&gt;</code> from base.html)? Secondly, how do I ensure I only pass <em>video sources in page</em> to my JS snippet? </p>

<p>Can someone give me an illustrative example via which I can solve this?</p>