title: Better ways to handle dynamically generated forms in Django
body: <p>I have a form that allow users to log their activities. To make it simple, let's say I only have two fields that I want a user to fill out. </p>
  
  <ul>
  <li>Time</li>
  <li>Action</li>
  </ul>
  
  <p>During a day, a user can fill out multiple time + action pairs. I used javascript on the front end to allow users to add these pairs as they wish.</p>
  
  <p>Thus, I do not know how many pairs there will be beforehand. And thus, I cannot create a predefined ModelForm for it. </p>
  
  <p>To deal with this issue, I labeled each Time and Action field with a unique name. So when I receive a POST request, I geta list like this inside the request.POST dictionary:</p>
  
  <ul>
  <li>time_1: 9:50</li>
  <li>action_1: wakeup</li>
  <li>time_2: 11:00</li>
  <li>aciton_2: workout</li>
  <li>...</li>
  </ul>
  
  <p>Then, I subtract each pair out of the dictionary and put them into a ModelForm for validation and save to the database.</p>
  
  <pre><code>class TimeActionModel(Model):
      time = DateField()
      action = CharField(max_length=100)
  
  class TimeActionForm(ModelForm):
      class Meta:
          model = TimeActionModel
  
  class TimeActionView(View):
      def post(self, request, *args, **kwargs):
          self._subtract_and_save(request)
  
      def _subtract_and_save(request):
          #loop through the request.POST dictionary
              #pull out each pair
              #stuff each one into a ModelForm object
              if form.is_valid():
                  form.save()
  </code></pre>
  
  <p>Here is my quesiton:  </p>
  
  <ul>
  <li>Does this approach look right to you?  </li>
  <li>What's the 'Django way' of dealing with such situation?</li>
  </ul>
  
  <p>Thank you!</p>