title: Extra fields in Django ModelForms: I can see them, but cannot save them to the model. Why?
body: <p>In my Django application, I am using a ModelForm to get my user to enter a street address. 
  I want clean this address, perform USPS validation on it, then geocode it. If all those steps succeed, I would like to save the dirty and cleaned version into my <code>Location</code> model which is shown below.</p>
  
  <pre><code>from localflavor.us.us_states import US_STATES
  from django.contrib.gis.db import models
  
  class Location(models.Model):
      # I want the user to enter these fields using a Model Form
      streetAddress = models.CharField(blank=False, null=False, max_length=300)
      city = models.CharField(null=False, blank=False,  max_length=50)
      state = USStateField(choices = US_STATES, null=False,)
      zip = models.CharField(null=False, max_length=10, )
  
      # I want to automatically derive these fields without any user intervention.
      # These fields are going to be calculated during the form validation process. 
      cleanedStreetAddress = models.CharField(blank=False, null=False, max_length=300)
      cleanedCity = models.CharField(null=True, blank=True,  max_length=50)
      cleanedState = USStateField(choices = US_STATES, null=False,)
      cleanedZip5 = models.CharField(null=False, max_length=5, )
      cleanedZip4 = models.CharField(null=False, max_length=4, )
      geoCoords = models.PointField(null=False, blank=False,)
  </code></pre>
  
  <p>In my corresponding ModelForm (named <code>LocationForm</code>), I have <code>fields = ["streetAddress", "city", "state", "zip",]</code>. I populate the remaining 6 fields by manually adding them to the dictionary being returned by the <code>LocationForm.clean()</code> method. So far, so good. No problems.</p>
  
  <p>In the corresponding class based view, I process the form in the <code>form_valid()</code> method, like this:</p>
  
  <pre><code>class InputLocationView(FormView):
      template_name = "helloWorld.html"
      form_class = LocationForm
      success_url = "/helloWorld"
  
  
      def form_valid(self, form):
          print "form.cleaned_data = %s" % form.cleaned_data
          ###
          # Output of the line above: 
          # form.cleaned_data = {'cleanedZip4': '0000', 'streetAddress': u'123 Main Street', 
          # 'zip': u'90210', 'cleanedStreetAddress': '123 MAIN ST', 'cleanedState': 'CO',
          # 'geoCoords': &lt;Point object at 0x10a1b4e20&gt;, 'state': u'CO', 'city': u'Anytown',
          # 'cleanedCity': 'ANYTOWN', 'cleanedZip5': '90210'}
          ###
          print "form.cleaned_data['geoCoords'] = (%s, %s)" % (form.cleaned_data['geoCoords'].x, form.cleaned_data['geoCoords'].y)
          # Output of the line above: form.cleaned_data['geoCoords'] = (-77.260768, 39.113707)
  
          newLocation = form.save(commit=False)
          newLocation.save()
  </code></pre>
  
  <p>As you can see from my comments above, the derived data that I added in the LocationForm.clean() is present in the class-based-view. That's good news. However, when it gets to newLocation.save(), it blows up with the following error:</p>
  
  <pre><code>null value in column "geoCoords" violates not-null constraint
  DETAIL:  Failing row contains (3, 123 Main Street, , Anytown, CO, 90210, , null,
   , , , null)
  </code></pre>
  
  <p>Why is <code>newLocation.save()</code> not including any of my derived data, when clearly all that data is present in the <code>form.cleaned_data</code> dictionary? How do I make sure <strong>all</strong> the data from <code>form.cleaned_data</code> makes it into the SQL Insert statement?</p>