title: Django: validating unique_together constraints in a ModelForm with excluded fields
body: <p>I have a form:</p>
  
  <pre><code>class CourseStudentForm(forms.ModelForm):
  
      class Meta:
          model = CourseStudent
          exclude = ['user']
  </code></pre>
  
  <p>for a model with some complicated requirements:</p>
  
  <pre><code>class CourseStudent(models.Model):
  
      user = models.ForeignKey(settings.AUTH_USER_MODEL)
      semester = models.ForeignKey(Semester)
      block = models.ForeignKey(Block)
      course = models.ForeignKey(Course)
      grade = models.PositiveIntegerField()
  
      class Meta:
          unique_together = (
              ('semester', 'block', 'user'), 
              ('user','course','grade'),
          )
  </code></pre>
  
  <p>I want the new object to use the current logged in user for CourseStudent.user:</p>
  
  <pre><code>class CourseStudentCreate(CreateView):
      model = CourseStudent
      form_class = CourseStudentForm
      success_url = reverse_lazy('quests:quests')
  
  
      def form_valid(self, form):
          form.instance.user = self.request.user
          return super(CourseStudentCreate, self).form_valid(form)
  </code></pre>
  
  <p>This works, however, because the user is not part of the form, it misses the validation that Django would otherwise do with the unique_together constraints.</p>
  
  <p>How can I get my form and view to use Django's validation on these constraints rather than having to write my own?  </p>
  
  <p>I though of passing the user in a hidden field in the form (rather than exclude it), but that appears to be unsafe (i.e. the user value could be changed)?</p>