title: Django auto generated form-fields
body: <p>What I want to do is some of the fields in my form to be automatically added according to the previous value. Let me show you my example:</p>
  
  <p><strong><em>my model</em></strong></p>
  
  <pre><code>class Measurement(models.Model):
      group = models.CharField(max_length=250)
      subgroup = models.CharField(max_length=250)
      number=models.PositiveIntegerField(default=1)
      voltage= models.PositiveIntegerField()
      comment = models.TextField(default='no comment')
      created = models.DateTimeField(auto_now_add=True)
  
      def __str__(self):
          return self.group
  </code></pre>
  
  <p><strong><em>forms.py</em></strong></p>
  
  <pre><code>class MeasurementForm(forms.ModelForm):
      class Meta:
          model = Measurement
          fields = ['group','subgroup','number','voltage','comment']
  </code></pre>
  
  <p><strong><em>my views.py</em></strong></p>
  
  <pre><code>def measurement(request):
      if request.method == "POST":
          form = MeasurementForm(request.POST, request.FILES)
          if form.is_valid():
              measurement = form.save(commit=False)
              measurement.save()
              return redirect('data:measurement')
      else:
          form = MeasurementForm()
      context = {'form': form,}
      template = 'data/measurement.html'
      return render(request, template, context)
  </code></pre>
  
  <p><strong><em>html.file</em></strong></p>
  
  <pre><code>            &lt;div class="panel panel-primary"&gt;
                  &lt;div class="panel-heading"&gt;
                      &lt;h4&gt;Add a measurement&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;form method='POST' enctype="multipart/form-data"&gt;
                      {% csrf_token %}
                      {{ form|crispy }}
                      &lt;button type = 'submit' class="btn btn-success"&gt;Save&lt;/button&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>What I would like to have though is the fields <code>group</code>, <code>subgroup</code> and <code>number</code> to be automatically generated according to what I entered before. 
  For example, first measurement I enter:</p>
  
  <p>Group:<code>House</code> Subgroup:<code>Light</code> Number:<code>1</code>  Voltage: <code>10</code> Comment: <code>No comment</code></p>
  
  <p>Once I click save I want the fields <code>Group</code>, <code>Subgroup</code> and <code>Number</code> to have the following information already:</p>
  
  <p>Group:<code>House</code> Subgroup:<code>Light</code> Number:<code>2</code>  Voltage: <code>12</code> Comment: <code>No comment</code></p>
  
  <p>The next one:</p>
  
  <p>Group:<code>House</code> Subgroup:<code>Light</code> Number:<code>3</code>  Voltage: <code>15</code> Comment: <code>No comment</code></p>
  
  <p>In order to add only my measurement and save time. However that does not mean that I can't change the  <code>Group</code>, <code>Subgroup</code> or <code>Number</code> fields.</p>