title: django form dropdown list of stored models
body: <p>I am trying to create a form for a library where a user can perform 2 actions: add a new book or open the stored information of an existing one. Books have 2 fields (title and author). 
  Every time a new book is created, it is stored at the database. Any previously created book is shown as an option at a dropdown list (only the name). I want that when a user selects an option from the dropdown list, the information of the selected book appears on screen.</p>
  
  <p>I have been trying 2 different approaches, but none of them fulfills my requirements.
  On one hand, following this question <a href="https://stackoverflow.com/questions/8859504/django-form-dropdown-list-of-numbers">django form dropdown list of numbers</a> I am able to create a dropdown list, and get the selected value at views with some code like that: </p>
  
  <pre><code>class CronForm(forms.Form):
      days = forms.ChoiceField(choices=[(x, x) for x in range(1, 32)])
  
  def manage_books(request):
      d = CronForm()
      if request.method == 'POST':
          day = request.POST.get('days')
  </code></pre>
  
  <p>But I want my options to be the previously stored books at the data base, and not pre-defined values.</p>
  
  <p>An other approach I have tried is to do it from the html template. There I create the following form:</p>
  
  <pre><code>&lt;form&gt;
      {% for book in list %} 
          &lt;option value="name"&gt;{{ book.name }}&lt;/option&gt;
      {% endfor %}   
  &lt;/form&gt;
  </code></pre>
  
  <p>Where book is rendered at views from this:</p>
  
  <pre><code>l = Books.objects.all().order_by('name')
  </code></pre>
  
  <p>In this second case the information shown at the dropdown list is the one I want, but I don't know how to get the selected value and use it at views. Perhaps using a javascript function?</p>
  
  <p>So my 2 requirements are: show the correct info at the list (the stored at the DB by the user) and be able to know which one has been selected.</p>