1👍
What about adding the cover reference to the MediaSet class and using the property decorator? This would save you the extra column in the manytomany table, and I assume you will never have more than one cover per album, right? Then this relationship should be reflected at the MediaSet class in my opinion. Then you could eventually also spare the SetContent class by the way.
class MediaSet(models.Model):
_cover = models.ForeignKey("Medium", blank=true, null=true, on_delete=models.SET_NULL)
media = models.ManyToManyField("Medium", related_name="albums")
@property
def cover(self):
if self._cover:
return self._cover
else:
return self.media.first()
@cover.setter
def cover(self, value):
self._cover = value
Source:stackexchange.com