title: Add form field data based on user input
body: <p>I'm trying to create a Quiz with a number of questions the user inputs in a form (also with a tag, but that's not the point here). I've tried the following but I do not feel this is the right approach. I am thinking there must be another way instead of manually calling Quiz.objects.create() with data I got from the form. Also even if the Quiz object gets created, I'm getting the following error:</p>
  
  <pre><code>'NoneType' object has no attribute '__dict__'
  </code></pre>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Quiz(models.Model):
      name = models.CharField(max_length=100)
      number_of_questions = models.IntegerField(default=5)
      time_limit = models.IntegerField(default=300)
      questions = models.ManyToManyField(Question)
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class QuizForm(forms.ModelForm):
      class Meta:
          model = Quiz
          exclude = ['questions']
  
      def save(self):
          data = self.cleaned_data
          questions = get_questions_with_tag('example_tag')
          questions = questions[:data['number_of_questions']]
          quiz = Quiz.objects.create(name=data['name'],
                                 time_limit=data['time_limit'],
                                 number_of_questions=data['number_of_questions'])
          for q in questions:
              quiz.questions.add(q)
  
          quiz.save()
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class AddQuizView(CreateView):
      template_name = 'quiz/cpanel/add_quiz.html'
      form_class = QuizForm
      success_url = reverse_lazy('list_quizzes')
  </code></pre>
  
  <p>Can you suggest a better approach that will involve only adding the questions list to the form request?</p>