第一个项目
This commit is contained in:
25
family_rpa/main/models.py
Normal file
25
family_rpa/main/models.py
Normal file
@@ -0,0 +1,25 @@
|
||||
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']
|
||||
Reference in New Issue
Block a user