title: Django - How to save() ModelForm's?
body: <p>I'm trying to save a ModelForm, but I'm getting an error:</p>
  
  <pre><code>InternalError at /submeter/anuncio/
  current transaction is aborted, commands ignored until end of transaction block
  </code></pre>
  
  <p>I will try to explain what I'm doing.</p>
  
  <p>Ok, I have 5 Models that I need to save at once in one form. I'm testing to save on two models but as I said, I'm getting error on the save method. As a beginner I'm getting a little bit lost on the best way to achieve the task.</p>
  
  <p>What I've done:</p>
  
  <p>Template:</p>
  
  <pre><code>&lt;form method="post" action="/submeter/anuncio/"&gt;{% csrf_token %}
      {{form_main}}
      {{form_bicyclead}}
      &lt;input type="hidden" name="section" value="5" /&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Views.py:</p>
  
  <pre><code>def submit_data_entry_view(request):
      if request.method == 'GET': #first time rendering the form
      form_main      = MainForm()
      form_bicyclead = BicycleAdForm()
  
      return render_to_response('app_t/submit_data_entry.html', {'form_main': form_main, 'form_bicyclead': form_bicyclead}, context_instance=RequestContext(request))
  
  def submit_ad_view(request):
      if request.method == 'POST':
          post_values = request.POST.copy()
  
          post_values['user'] = request.user.username
  
          post_values['bicycleadtype']      = 2
          post_values['bicycleaditemkind']  = 4
          post_values['bicycleadcondition'] = 2
          post_values['city']               = 4803854  
  
          form_main      = MainForm(post_values)
          form_bicyclead = BicycleAdForm(post_values)
  
      if form_main.is_valid() and form_bicyclead.is_valid():
          form_main.save()
          #form_bicyclead.save()
  
          resultado = 'valid'
      else:
          resultado = 'n_valid'
      pdb.set_trace()
  
      return render_to_response('app_t/submit_ad.html', {'resultado': resultado}, context_instance=RequestContext(request))
  </code></pre>
  
  <p>Forms.py:</p>
  
  <pre><code>class MainForm(forms.ModelForm):
      class Meta:
      model = Main
      exclude = ('user', 'section')
  
  class BicycleAdForm(forms.ModelForm):
      class Meta:
      model = BicycleAd
      exclude = ('main', 'bicycleadtype', 'bicycleaditemkind', 'bicycleadcondition', 'city')
  </code></pre>
  
  <p>Models.py:</p>
  
  <pre><code>class Main(models.Model):
      section             = models.ForeignKey(Section)
      user                = models.ForeignKey(User)
      title               = models.CharField(max_length=250)
      date_inserted       = models.DateTimeField(auto_now_add=True)
      date_last_update    = models.DateTimeField(auto_now=True)
  
      def __unicode__(self):
      return self.title
  
      class Meta:
      ordering = ['date_inserted']
  
  class BicycleAd(models.Model):
      main                = models.ForeignKey(Main)
      bicycleadtype       = models.ForeignKey(BicycleAdType)
      bicycleaditemkind   = models.ForeignKey(BicycleAdItemKind) # MPTT Model
      bicycleadcondition  = models.ForeignKey(BicycleAdCondition)
      country             = models.ForeignKey(GeonamesCountry)       
      city                = models.ForeignKey(GeonamesLocal) 
      date_inserted       = models.DateTimeField(auto_now_add=True)
      date_last_update    = models.DateTimeField(auto_now=True)
  
      class Meta:
      ordering = ['date_inserted']  
  </code></pre>
  
  <p>My question is: How can I "override" the form_main.save()  in the views.py and tell them all the fields that I have in the model "section, user and title"? I think the error is because of the fields "section" and "user" that are not passing to the save method. How can I pass this values?</p>
  
  <p>Another question: I'm doing this the right way or there are easier and simple ways to achieve what I'm trying to achieve?</p>
  
  <p>Best Regards</p>