Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Make migrations is not detecting many to many field in model

Following are my models:

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)

No matter what i do, make migrations is not detecting this many to many field. Can someone please help?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You put conversation: models.ManyToManyField(Message) instead of conversation=models.ManyToManyField(Message)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading