26 lines
837 B
Python
26 lines
837 B
Python
from django.db import models
|
|
from django.utils import timezone
|
|
from django.contrib.auth.models import User
|
|
|
|
class File(models.Model):
|
|
owner = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
|
|
file = models.FileField(upload_to='uploads/')
|
|
description = models.TextField(blank=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
is_public = models.BooleanField(default=True)
|
|
|
|
def __str__(self):
|
|
return self.file.name
|
|
|
|
class Message(models.Model):
|
|
author = models.CharField(max_length=100)
|
|
content = models.TextField()
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
ip_address = models.GenericIPAddressField(null=True, blank=True)
|
|
|
|
def __str__(self):
|
|
return f"来自 {self.author} 的留言"
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|