from django.db import models class File(models.Model): name = models.CharField(max_length=500, help_text="Display name or filename") path = models.CharField(max_length=1000, blank=True, help_text="Path relative to content root") mime_type = models.CharField(max_length=100, help_text="MIME type of the entity (e.g. application/pdf, application/x-folder)") parent = models.ForeignKey( 'self', on_delete=models.CASCADE, null=True, blank=True, related_name='children', help_text="Parent folder or parent document (for sidecars/sub-entries)" ) # File storage file_content = models.FileField(upload_to='uploads/', null=True, blank=True, help_text="Uploaded file content") # Content storage text = models.TextField(blank=True, help_text="Text content, OCR, or embedded query") external_url = models.URLField(blank=True, help_text="External link (e.g. YouTube)") # Metadata metadata = models.JSONField(default=dict, blank=True, help_text="Frontmatter (created_at, user, etc.)") # Ownership and house-keeping user = models.ForeignKey('quiz.QuizUser', on_delete=models.CASCADE, related_name='files') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: verbose_name = "File" verbose_name_plural = "Files" def __str__(self): return f"[{self.mime_type}] {self.name}"