擅长:python、mysql、java
<blockquote>
<p>NOTE: This answer as modified, according to Larry's code. Previous solution extended fields.BigIntegerField, but better to extend fields.AutoField</p>
</blockquote>
<p>我也有同样的问题,用以下代码解决:</p>
<pre><code>from django.db.models import fields
from south.modelsinspector import add_introspection_rules
class BigAutoField(fields.AutoField):
def db_type(self, connection):
if 'mysql' in connection.__class__.__module__:
return 'bigint AUTO_INCREMENT'
return super(BigAutoField, self).db_type(connection)
add_introspection_rules([], ["^MYAPP\.fields\.BigAutoField"])
</code></pre>
<p>很明显,这对南部移民来说效果不错。</p>