我的一個Django的網站具有以下數據庫模型: 在Django應用程序「常見」:Django管理變化的形式加載很慢
class Collection(models.Model):
name = models.CharField(max_length = 255, unique = True)
_short_name = models.CharField(db_column="short_name", max_length = 32, blank=True)
class Particle(models.Model):
content = models.TextField(blank=False)
owner = models.ForeignKey(Collection)
order = models.IntegerField(null=True, blank=True)
在Django應用程序「情景喜劇」:
class Media(models.Model):
name = models.CharField(max_length = 248)
_short_name = models.CharField(db_column="short_name", max_length = 32, blank=True)
capital = models.CharField(max_length = 1)
description = models.TextField(blank=True)
progress = models.CharField(max_length = 32, blank=True, null=True)
class Relation(models.Model):
name = models.CharField(max_length = 128)
_short_name = models.CharField(db_column="short_name", max_length = 32, blank=True)
description = models.TextField(blank=True)
parent = models.ForeignKey('self', blank=True, null=True)
order = models.IntegerField(blank=True, null=True)
particle = models.ForeignKey(Particle, blank=True, null=True)
media = models.ForeignKey(Media, blank=True, null=True)
在簡而言之,模型類Relation有3個外鍵給其他表。 問題是,當我使用Django Admin更改單個關係時,頁面(change_form)加載得相當緩慢。 後來,我改變了模型類的關係如下:
class Relation(models.Model):
name = models.CharField(max_length = 128)
_short_name = models.CharField(db_column="short_name", max_length = 32, blank=True)
description = models.TextField(blank=True)
order = models.IntegerField(blank=True, null=True)
parent_id = models.IntegerField(blank=True, null=True)
particle_id = models.IntegerField(blank=True, null=True)
media_id = models.IntegerField(blank=True, null=True)
修改改變外鍵IntegerFields,所以它禁用了一些Django的ORM系統裏面的魔法,現在的變化形式的頁面加載的真快。 我的問題是,什麼是「django orm裏面的殘疾魔法師」?有什麼可能導致問題?
非常感謝!它工作,現在我可以再次使用ForeignKey,它更方便。 – Brent81