I have a django app that stores email threads. When I parse the original emails from an mbox and insert them into the database I include the email header parameters 'message-id' and 'in-reply-to'. The message-id is a unique string that identifies the message, and the in-reply-to identifies a message that a given message is in response to.
Here is the message portion of my model:
class Message(models.Model):
subject = models.CharField(max_length=300, blank=True, null=True)
mesg_id = models.CharField(max_length=150, blank=True, null=True)
in_reply_to = models.CharField(max_length=150, blank=True, null=True)
orig_body = models.TextField(blank=True, null=True)
The goal is to be able to show email conversations in a threaded format similar to gmail. I was planning on just using the message-id (mesg_id in model) and in-reply-to (in_reply_to in model) from the mail headers to keep track of the mail and do the threading.
After reviewing SO and google it looks like I should be using a library like django-treebeard or django-mptt to do this. When I review the documentation for either of these two solutions it looks like most of the models are using foreign key relationships and this confuses me.
Given the example model above, how can I implement either django-treebeard or django-mptt into my app? Is this possible using the mesg_id and in_reply_to fields?