title: Validation for dynamic radio buttons
body: <p>I want to know how to check if a radio button has been selected before the user clicks submit. At the moment it allows a submission if nothing has been selected.</p>
  
  <p>remove.html</p>
  
  <pre><code>{%for laptop in laptops%}
      &lt;form action = "{%url 'laptops:delete'%}" method = "post" enctype="multipart/form-data"&gt;
          {% csrf_token %}
          &lt;div class="radio"&gt;
    &lt;input type="radio" id = "laptop_{{laptop.id}}" name="laptopname" value = "{{laptop.id}}"&gt;
              &lt;label for = "laptop_{{laptop.id}}"&gt;{{laptop}}&lt;/label&gt;
  &lt;/div&gt;
  {%endfor%}
  &lt;input type="submit" value="Submit" id="delete-button"/&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>#Gets id value from the 'laptopname' radio button
  laptopid = int(request.POST.get('laptopname'))
  #Finds matching id value
  laptop = Laptop.objects.get(id=laptopid)
  #Populates form with matching data
  data = {'Name': laptop.Name, 'specification': laptop.specification,'warranty': laptop.warranty,
      'condition':laptop.condition}
  form = forms.MakeSale(initial=data)
  return render(request, 'laptops/laptop_sale.html', {'form': form})
  </code></pre>
  
  <p>Is my approach wrong? Should I be doing the validation using a form for the radio buttons instead?</p>