title: Django - Can't Initialize Selected Radio Button when using ModelChoiceField with RadioSelect Widget
body: <p>I have a form that I want to be pre-populated with data from a model instance when a user is attempting to update an existing database record. When the form is rendered none of the radio buttons pre-selected even though a model instance has been passed to the ModelForm. In a much larger form than listed below, all of the fields except the radio buttons are pre-populated with the correct data from the model instance. How do I get the correct radio buttons pre-selected?</p>
  
  <p><strong>My Models:</strong></p>
  
  <pre><code>class TicketType(models.Model):
      type = models.CharField(max_length=15, unique=True)
  
      def __unicode__(self):
          return self.type.title()
  
  
  class TestTicket(models.Model):
      ticket_type = models.ForeignKey(TicketType, to_field='type')
  </code></pre>
  
  <p><strong>My Form</strong></p>
  
  <pre><code>class TestTicketForm(ModelForm):
      ticket_type = ModelChoiceField(TicketType.objects.all(),
                                     widget=RadioSelect,
                                     empty_label=None)
      class Meta:
          model = TestTicket
          fields = ['ticket_type']
  </code></pre>
  
  <p><strong>My View</strong></p>
  
  <pre><code>def test_ticket_update(request, ticket_num=None):
  
      # initialize an update flag to distinguish between a request 
      # to add a new ticket or an update to an existing ticket.
      update_requested = False
      ticket_instance = None
  
      if ticket_num:
          # This is a request to update a specific ticket. 
          # Attempt to retrieve the ticket or show a 404 error.
          # If a ticket is retrieved, it is locked for editing 
          # by using 'select_for_update()' to prevent a race condition.
          ticket_instance = get_object_or_404(
                TestTicket.objects.select_for_update(),pk=ticket_num)
          update_requested = True
  
      if request.method == 'POST':
          form = TestTicketForm(request.POST, instance=ticket_instance)
          if form.is_valid():
              ticket = form.save(commit=False)
              ticket.save()
              return HttpResponseRedirect('/tickets/')
      else:
  
          if update_requested:
              # This is a requested to update an existing ticket. 
              # Bind the ticket data to a form.
              form = TestTicketForm(instance=ticket_instance)
          else:
              form = TestTicketForm()
  
      return render(request, 'ticket_tracker/ticket_update.html', 
                    { 'form': form, 'ticket': ticket_instance})
  </code></pre>
  
  <p><strong>My Template</strong></p>
  
  <pre><code>{% block content %}
  &lt;div class="container"&gt;
          &lt;form action="/tickets/test-ticket/{{ ticket.id }}/" method="post"&gt;
              {% csrf_token %}
              {{ form.as_p }}
  
              &lt;div class="form-group"&gt;
                  &lt;button type="submit"&gt;Save&lt;/button&gt;
              &lt;/div&gt;
  
          &lt;/form&gt;
  &lt;/div&gt;
  {% endblock content %}
  </code></pre>