title: Populating select menu using database elements - Python/Django/javascript/html
body: <p>As the title suggests, I am trying to populate an HTML select menu using elements from a database. Right now, I have a set of file systems (issp's) which are associated with a set of compatible operating systems (many-to-many relationship). When a user selects an issp version from the drop-down, I want its compatible operating systems to be displayed without hardcoding a bunch of javascript arrays.</p>
  
  <p>I have no problem populating my issp select menu from the database as the template is passed the full list of issp's as part of its context. However, because Django does not allow the use of python methods which take arguments, I'm having trouble populating the operating system menu. </p>
  
  <p>I want to do something <em>like</em> this (though I realize it's impossible this way, I'm looking for suggestions about an alternate route):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function populateSelect(select, osId) {
      $(osId).html("");
      var issp_version = $(select).val(); 
      for (i = 0; i &lt; { issp_list.filter(issp=issp_version).os_length }; i++) {
          $(osId).append('&lt;option value="{ issp_list.filter(issp=version).os.all()[i] }" display = ...")          </code></pre>
  </div>
  </div>
  </p>
  
  <p>Where osId is the id corresponding to each operating system select menu. and the function issp.os_length() is a user-defined method that just gives the length of the list of compatible operating systems.</p>