title: django forms give: Select a valid choice. That choice is not one of the available choices
body: <p>I am unable to catch the values from the <code>unit_id</code> after the selection is done by the user and data is posted. Can someone help me to solve this.</p>
  
  <p>The values of the <code>unit_id</code> drop down list is obtained from another database table (<code>LiveDataFeed</code>). And once a value is selected and form posted, it gives the error:</p>
  
  <p><em><strong>Select a valid choice. That choice is not one of the available choices.</em></strong></p>
  
  <p>Here is the implementation:</p>
  
  <p><strong>in models.py:</strong></p>
  
  <pre><code>class CommandData(models.Model):
      unit_id = models.CharField(max_length=50)
      command = models.CharField(max_length=50)
      communication_via = models.CharField(max_length=50)
      datetime = models.DateTimeField()
      status = models.CharField(max_length=50, choices=COMMAND_STATUS)  
  </code></pre>
  
  <p><strong>In views.py:</strong></p>
  
  <pre><code>class CommandSubmitForm(ModelForm):
      iquery = LiveDataFeed.objects.values_list('unit_id', flat=True).distinct()
      unit_id = forms.ModelChoiceField(queryset=iquery, empty_label='None',
          required=False, widget=forms.Select())
  
  class Meta:
      model = CommandData
      fields = ('unit_id', 'command', 'communication_via')
  
  def CommandSubmit(request):
      if request.method == 'POST':
          form = CommandSubmitForm(request.POST)
          if form.is_valid():
              form.save()
              return HttpResponsRedirect('/')
      else:
          form = CommandSubmitForm()
  
      return render_to_response('command_send.html', {'form': form},
          context_instance=RequestContext(request))
  </code></pre>