擅长:python、mysql、java
<p>手动创建id时,应该使用AutoField而不是IntegerField</p>
<pre><code>id_dato = models.AutoField(primary_key=True)
</code></pre>
<p><a href="https://docs.djangoproject.com/en/1.6/ref/models/fields/#autofield" rel="nofollow">https://docs.djangoproject.com/en/1.6/ref/models/fields/#autofield</a></p>
<p>由于您没有显式定义'datos'对象的id,因此它没有id,然后producto会抱怨,因为键不能有空值。在</p>
<p>AutoField应该可以解决这个问题</p>