2011-01-29 64 views

回答

43

除非另有规定,否则将为ForeignKey创建索引。相关源代码:

class ForeignKey(RelatedField, Field): 
    # snip 
    def __init__(self, to, to_field=None, rel_class=ManyToOneRel, **kwargs): 
     # snip 
     if 'db_index' not in kwargs: 
      kwargs['db_index'] = True 
+0

要禁用在ForeignKey上创建索引,请设置`db_index = False`:http://code.djangoproject.com/ticket/13730 – 2014-02-03 14:10:18

相关问题