更新时间:2023-12-01 21:58:28
来自 Django书:
如果需要在尚未创建的模型上创建关系定义后,您可以使用模型的名称,而不是模型对象本身:
If you need to create a relationship on a model that has not yet been defined, you can use the name of the model, rather than the model object itself:
例如:
class MenuItem(model.Models)
title = models.CharField(max_length=200)
submenus = models.ManyToManyField('Menu', blank=True, null=True)
^ ^