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

class Pdf(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    url = models.URLField(max_length=250, blank=True)  # For storing external URLs
    pdf = models.FileField(upload_to='user_pdfs/', blank=True, null=True)  # For file uploads
    name = models.CharField(max_length=100)
    created_at = models.DateTimeField(auto_now_add=True)
    
    def __str__(self):
        return f"{self.name} - {self.user.username}"