<filename>ndnu-connect-backend/boards/models.py
from django.db import models


class Board(models.Model):
    name = models.CharField(max_length=30, unique=True)
    description = models.CharField(max_length=100)

    def __str__(self):
        return self.name


class Topic(models.Model):
    subject = models.CharField(max_length=255)
    last_updated = models.DateTimeField(auto_now_add=True)
    board = models.ForeignKey(Board, related_name='topics', on_delete=models.CASCADE)
    starter = models.ForeignKey('accounts.User', related_name='topics', on_delete=models.CASCADE)

    def __str__(self):
        return self.board.name + ": " + self.subject


class Post(models.Model):
    message = models.TextField(max_length=4000)
    topic = models.ForeignKey(Topic, related_name='posts', on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(null=True)
    created_by = models.ForeignKey('accounts.User', related_name='posts', on_delete=models.CASCADE)
    updated_by = models.ForeignKey('accounts.User', null=True, blank=True,
                                   related_name='+', on_delete=models.CASCADE)

    def __str__(self):
        return "Post #" + str(self.id) + " for Topic '" + self.topic.subject + \
               "' by user " + self.created_by.email

<filename>ndnu-connect-backend/boards/models.py
from django.db import models


class Board(models.Model):
    name = models.CharField(max_length=30, unique=True)
    description = models.CharField(max_length=100)

    def __str__(self):
        return self.name


class Topic(models.Model):
    subject = models.CharField(max_length=255)
    last_updated = models.DateTimeField(auto_now_add=True)
    board = models.ForeignKey(Board, related_name='topics', on_delete=models.CASCADE)
    starter = models.ForeignKey('accounts.User', related_name='topics', on_delete=models.CASCADE)

    def __str__(self):
        return self.board.name + ": " + self.subject


class Post(models.Model):
    message = models.TextField(max_length=4000)
    topic = models.ForeignKey(Topic, related_name='posts', on_delete=models.CASCADE)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(null=True)
    created_by = models.ForeignKey('accounts.User', related_name='posts', on_delete=models.CASCADE)
    updated_by = models.ForeignKey('accounts.User', null=True, blank=True,
                                   related_name='+', on_delete=models.CASCADE)

    def __str__(self):
        return "Post #" + str(self.id) + " for Topic '" + self.topic.subject + \
               "' by user " + self.created_by.email

#" + str(self.id) + " for Topic '" + self.topic.subject + \