2011-01-29 52 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

相關問題