I have a theoretical model that isn't working:
class Message(models.Model):
text = models.TextField()
created = models.DateTimeField(auto_now_add=True)
sender = models.ForeignKey(User)
receiver = models.ForeignKey(User)
Now if a user messaged someone, like a private message thread, you have someone who sent it, and someone who received it, which is important to know. Both of these should be a one-to-many I think because each user can send infinite messages. Senders and receivers are users, from the same model User, but they must be different people. I get django whining about
django.core.management.base.CommandError: System check identified some issues:
ERRORS:
chat.Message.receiver: (fields.E304) Reverse accessor for 'Message.receiver' clashes with reverse accessor for 'Message.sender'.
HINT: Add or change a related_name argument to the definition for 'Message.receiver' or 'Message.sender'.
chat.Message.sender: (fields.E304) Reverse accessor for 'Message.sender' clashes with reverse accessor for 'Message.receiver'.
HINT: Add or change a related_name argument to the definition for 'Message.sender' or 'Message.receiver'.
Should I add unique=True
since you can't send messages to yourself? Is this a bad way to implement messages between users? And what is my error? Thank you,
Cody