title: Error: int() argument must be a string or a number, not 'NoneType' saving new records Django
body: <p>I have some issues trying to save new records in the database, using <code>model.Autofield</code></p>
  
  <p><strong><code>models.py</code></strong>:</p>
  
  <pre><code>class Proveedor(models.Model):
      id_proveedor = models.AutoField(primary_key=True, db_column='id_proveedor')
      nombre = models.CharField(max_length=50)
      tipo = models.CharField(max_length=50)
      asignado_a = models.CharField(max_length=15,verbose_name='Asignado a')
      moneda = models.CharField(max_length=1, blank=True)
      class Meta:
          managed = False
          db_table = 'mpc_proveedores'
  
      def __unicode__(self):
          return self.nombre
  </code></pre>
  
  <p><strong>My form</strong>:</p>
  
  <pre><code>class ProvForm(forms.ModelForm):
      def __init__(self,*args,**kwargs):
         super(ProvForm,self).__init__(*args,**kwargs)
         self.helper = FormHelper(self)
         self.helper.layout.append(Submit('save','Grabar'))
      class Meta:
         model = Proveedor
  </code></pre>
  
  <p><strong>My view</strong>:</p>
  
  <pre><code>@login_required(login_url='/login/')
  def proveedores(request):
      form = ProvForm(request.POST or None)
  
      if form.is_valid():
         form.save()
         messages.success(request, 'Proveedor Grabado')
         return HttpResponseRedirect('/monitor/')
  
      return render_to_response("proveedor.html",
                                 locals(),
                                 context_instance=RequestContext(request))
  </code></pre>
  
  <p>When I try  to save the new record I receive the error:</p>
  
  <pre><code>int() argument must be a string or a number, not 'NoneType'
  </code></pre>
  
  <p>Apparently the form receive the <code>id_proveedor</code> empty. I am not sure if is necessary to pass the value in the form definition or in the view definition. And I want to know if is possible save some fields of this form on a another model, without using database triggers.</p>
  
  <p>Any advice?</p>