擅长:python、mysql、java
<p>很久以前,Autofield有个问题。</p>
<p><a href="https://code.djangoproject.com/ticket/17653" rel="nofollow">https://code.djangoproject.com/ticket/17653</a></p>
<p>有趣的引语:</p>
<p>答:</p>
<blockquote>
<p>It seems you are trying to save 0 to a ForeignKey which points to an
AutoField. But, this is illegal, as the AutoField will not accept that
value and so the ForeignKey can not hold that value either.</p>
</blockquote>
<p>乙:</p>
<blockquote>
<p>So this fix creates another problem when you need to be able to accept
a value of 0 (or if you are working on a DB that already has a value
of 0!) in an autofield. In my case, I need to accept an ID of zero so
that my foreign key can point to zero so that a unique constraint can
work properly.</p>
</blockquote>
<p>看起来你在<code>"user"."user_id"</code>中有<code>0</code>。<br/>
但是再一次。。。完整的堆栈跟踪,请。。。</p>