from django.db import models from apps.account.models import StudentUser, User from apps.course.models import Course class Participant(models.Model): student = models.ForeignKey( StudentUser, on_delete=models.CASCADE, related_name='participated_courses' ) course = models.ForeignKey( Course, on_delete=models.CASCADE, related_name='participants' ) joined_date = models.DateTimeField(auto_now_add=True) unread_messages_count = models.IntegerField(default=0) class Meta: unique_together = ('student', 'course')