1
class PortalContent(models.Model):
movies = models.ForeignKey(Movie, db_column="movies_id")
portalID = models.IntegerField()
projectID = models.IntegerField(default=0)
contentType = models.CharField(max_length=100)
licenseTerms = models.TextField()
createDate = models.DateTimeField(auto_now=True)
我有上面的模型。這個模型有一個通過外鍵與Movie Model相關的字段。帶外鍵訪問的Django休息模式
Now when I view the list /portalContent/1/
該數據需要超過2秒的加載。電影表只有20K條記錄。不知道爲什麼這需要這麼多時間。我使用了debug_toolbar,它顯示了一個查詢,即從電影中選擇*取1.6s。這兩個表都有索引定義。
任何人都可以指導我
您使用的是可瀏覽管理界面?如果你是... http://stackoverflow.com/questions/22173425/limit-choices-to-foreignkey-in-django-rest-framework – demux