from django.db import models
from django.conf import settings
from django.utils import timezone

User = settings.AUTH_USER_MODEL

class Follow(models.Model):
    follower = models.ForeignKey(
        User, related_name="following_relations", on_delete=models.CASCADE
    )
    following = models.ForeignKey(
        User, related_name="follower_relations", on_delete=models.CASCADE
    )
    created_at = models.DateTimeField(default=timezone.now)

    class Meta:
        unique_together = ("follower", "following")  # Prevent duplicate follows

    def __str__(self):
        return f"{self.follower} follows {self.following}"
