title: Django manytomany through create form and view
body: <p>I'm new in Django and I'm building a job board.
  But I don't understand how to create a form to get related fields of a M2M through.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#views.py
  class JobDetails(generic.DetailView):
  
      model = Job
      template_name = 'companies/job-detail.html'
  
      def get_context_data(self, **kwargs):
          context = super(JobDetails, self).get_context_data(**kwargs)
          context['company_detail'] = Company.objects.all()
          return context
  
      def apply(request):
          if request.method == "POST":
              form = ApplyForm(request.POST)
              if form.is_valid():
                   form.save(commit=False)
  
                  #create job
                  job = Job.objects.all.get(pk=pk)
  
                  #create candidate
                  candidate = User.objects.all.get(pk=pk)
  
                  #assign to the through table
                  candidatetojob = CandidateToJob.objects.create(job=job, candidate=candidate)
  
  
                  form.save()
                  candidatetojob.save()   
  
  
  
                   return HttpResponseRedirect('/jobs/')
           else:
                  form = ApplyForm()
  
           return render_to_response(
               "companies/form-candtojob.html",
               {'form': form}
           )
  
  
   #forms.py
   class ApplyForm(ModelForm):
  
      class Meta:
          model = CandidateToJob
          exclude = ['candidate', 'job', 'status']
  
  
   #models.py
   class Job(models.Model):
      company = models.ForeignKey(Company)
      candidate = models.ManyToManyField('Candidate', through='CandidateToJob')
      title = models.CharField(max_length=500)
      pub_date = models.DateField(auto_now_add=True)
      ...
  
      def __unicode__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse('jobdetail', kwargs={'pk': self.pk})
  
   class Candidate(models.Model):
      user = models.OneToOneField(User, primary_key=True)
      photo = models.ImageField(upload_to='candidateprofile/%Y/%m/%d')
      ...
  
      def __unicode__(self):
         return self.user.username
  
  
   class CandidateToJob(models.Model):
      job = models.ForeignKey(Job, related_name='applied_to')
      candidate = models.ForeignKey(Candidate, related_name='from_user')
      STATUS_CHOICES = (
          ('0', 'New'),
          ('1', 'Not approved'),
          ('2', 'Approved'),
          ('3', 'Hired')
       )
      status = models.CharField(max_length=2, choices=STATUS_CHOICES)
  
      def __unicode__(self):
          return self.job.candidate.user.username
  </code></pre>
  
  <p>But in my template.html, the user candidate being loggedin apply for a job (by submit form button) I get a 405 error. I am only allowed to perform this in the admin.</p>
  
  <p>Some thoughts of what am I doing wrong?
  Thanks in advance.</p>