Files
funnywolf b6b4cbf017 0.4.0 I always have a choice
You shape nothing until you hold everything.
2026-06-27 19:08:48 +08:00

24 lines
700 B
Python

import uuid
from django.conf import settings
from django.db import models
class Attachment(models.Model):
access_key = models.UUIDField(default=uuid.uuid4, unique=True, editable=False)
file = models.FileField(upload_to="attachments/%Y/%m/")
filename = models.CharField(max_length=255)
size = models.PositiveIntegerField()
uploaded_by = models.ForeignKey(
settings.AUTH_USER_MODEL, null=True, blank=True,
on_delete=models.SET_NULL, related_name="attachments"
)
uploaded_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "attachments"
ordering = ["-uploaded_at"]
def __str__(self):
return self.filename