I want to access the actual ID of the sender, right now I can only access the email of the sender.
This is the Javascript
fetch(`/emails/${id}`)
.then(response => response.json())
.then(email => {
subject = email.subject
sender = email.sender
recipients = email.recipients
timestamp = email.timestamp
body = email.body
}
This is the model in Django
class Email(models.Model):
user = models.ForeignKey("User", on_delete=models.CASCADE, related_name="emails")
sender = models.ForeignKey("User", on_delete=models.PROTECT, related_name="emails_sent")
recipients = models.ManyToManyField("User", related_name="emails_received")
subject = models.CharField(max_length=255)
body = models.TextField(blank=True)
timestamp = models.DateTimeField(auto_now_add=True)
archived = models.BooleanField(default=False)
read = models.BooleanField(default=False)