class PinnedVideo(models.Model):
pinned_video = models.OneToOneField(Video, on_delete=models.CASCADE)
pinning_user = models.OneToOneField(CustomUser, on_delete=models.CASCADE)
class Meta:
constraints = [
CheckConstraint(
check = Q(pinned_video = F("pinning_user")),
name = "user_and_video_author_same",
)
]
Trying to make a constraint that will guarantee that the pinned_videos author is the same as the pinning user, but just cant get it to work.