进行迁移未检测到模型中的多对多字段
Make migrations is not detecting many to many field in model
以下是我的模型:
class Message(models.Model):
sender = models.ForeignKey(
to=Profile, on_delete=models.CASCADE, related_name="sender", null=True) # This null is temporary will remove it
receiver = models.ForeignKey(
to=Profile, on_delete=models.CASCADE, related_name="receiver", null=True) # This null is temporary will remove it
text = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.text
class Meta:
ordering = ["timestamp"]
class Chat(models.Model):
conversation: models.ManyToManyField(Message) #---> This field is not being detected.
first_participant = models.ForeignKey(
Profile, on_delete=models.CASCADE, related_name="first_participant")
second_participant = models.ForeignKey(
Profile, on_delete=models.CASCADE, related_name="second_participant")
date_modified = models.DateTimeField(auto_now=True)
无论我做什么,make migrations 都检测不到这个多对多字段。有人可以帮忙吗?
你输入 conversation: models.ManyToManyField(Message)
而不是 conversation=models.ManyToManyField(Message)
以下是我的模型:
class Message(models.Model):
sender = models.ForeignKey(
to=Profile, on_delete=models.CASCADE, related_name="sender", null=True) # This null is temporary will remove it
receiver = models.ForeignKey(
to=Profile, on_delete=models.CASCADE, related_name="receiver", null=True) # This null is temporary will remove it
text = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.text
class Meta:
ordering = ["timestamp"]
class Chat(models.Model):
conversation: models.ManyToManyField(Message) #---> This field is not being detected.
first_participant = models.ForeignKey(
Profile, on_delete=models.CASCADE, related_name="first_participant")
second_participant = models.ForeignKey(
Profile, on_delete=models.CASCADE, related_name="second_participant")
date_modified = models.DateTimeField(auto_now=True)
无论我做什么,make migrations 都检测不到这个多对多字段。有人可以帮忙吗?
你输入 conversation: models.ManyToManyField(Message)
而不是 conversation=models.ManyToManyField(Message)