title: Django Cannot Insert ForeignKey into Database : It's Error ,MultiValueDictKeyError
body: <p>I try to Insert Foreign Key into the database. But When I hit the submit, I get</p>
  
  <blockquote>
    <p>Error:MultiValueDictKeyError</p>
  </blockquote>
  
  <h3>model.py</h3>
  
  <pre><code>from django.db import models
  
  class Candidate_Military(models.Model):
      """docstring forCandidate_Military."""
      auto_increment_id = models.AutoField(primary_key=True)
      military_status = models.CharField(max_length=100,null=True)
      military_reason = models.CharField(max_length=250,null=True)
  
      def __int__(self):
          return self.auto_increment_id
  
  class Candidate_Basic(models.Model):
      """docstring for Candidate_basic."""
      id_number = models.CharField(primary_key=True,max_length=13)
      position = models.CharField(max_length=250)
      salary = models.IntegerField()
      profile_pic = models.ImageField()
      nickname = models.CharField(max_length=100)
      name_title = models.CharField(max_length=50)
      firstname = models.CharField(max_length=250)
      lastname = models.CharField(max_length=250)
      candidate_military = models.ForeignKey(Candidate_Military, on_delete=models.CASCADE,null=True)
      def __int__(self):
          return self.id_number
  </code></pre>
  
  <h3>view.py</h3>
  
  <pre><code>from .models import Candidate_Basic, Candidate_Military
  
  def index(request):
      template=loader.get_template("index.html")
      return HttpResponse(template.render())
  
  def submit_applyjob(request):
      print("ohh! It's sumbitted!")
  
      military_status = request.POST.get('military_status')
      military_reason = request.POST.get('military_reason')
  
      candidate_military = Candidate_Military(military_status=military_status,military_reason=military_reason)
      candidate_military.save()
  
      id_number = request.POST["id_number"]
      position = request.POST["position"]
      salary = request.POST["salary"]
      profile_pic = request.POST["profile_pic"]
      nickname = request.POST["nickname"]
      name_title = request.POST["name_title"]
      firstname = request.POST["firstname"]
      lastname = request.POST["lastname"]
      print("candidate_military" + "--&gt;&gt;&gt;" + str(candidate_military))
      candidate_military = request.POST["candidate_military"]
  
      candidate_basic = Candidate_Basic(id_number=id_number,position=position,salary=salary,
      profile_pic=profile_pic,nickname=nickname,name_title=name_title,
      firstname=firstname,lastname=lastname,candidate_military=candidate_military)
      candidate_basic.save()
  
      return render(request, "index.html")
  </code></pre>
  
  <p>And When I fill the form and hit the submit button It's Error Like This</p>
  
  <p><img src="https://i.stack.imgur.com/7o1uo.png" alt="enter image description here"></p>
  
  <p>I don't Understand Why It cannot insert into my database. I try to print the value of 'candidate_military' It's Print the right value! </p>
  
  <p><img src="https://i.stack.imgur.com/F77u4.png" alt="enter image description here"></p>
  
  <p>Plz Help me to Debug This issue T^T</p>
  
  <p>I try to fix this code with</p>
  
  <pre><code>candidate_military = request.POST.get("candidate_military",False)
  </code></pre>
  
  <p>But It's not Work ; </p>
  
  <blockquote>
    <p>ValueError: Cannot assign "False": "Candidate_Basic.candidate_military" must be a "Candidate_Military" instance.</p>
  </blockquote>