from django.db import models
import uuid
from django.conf import settings
from . import Device

class LoginLog(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='login_logs')
    device = models.ForeignKey(Device, on_delete=models.SET_NULL, related_name='login_logs', null=True)
    date = models.DateTimeField(auto_now=True)

    def __str__(self):
        return f"{self.id} > {self.user.username}"
