You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
666 B

from django.db import models
from django.utils import timezone
# Create your models here.
class Blog(models.Model):
title = models.CharField('标题',max_length=200)
author = models.ForeignKey('auth.User',on_delete=models.SET_NULL,null=True,
verbose_name='作者')
content = models.TextField('内容')
create_time = models.DateTimeField('创建时间', default=timezone.now)
modify_time = models.DateTimeField('修改时间', auto_now=True)
def __str__(self):
return self.title
def author_name(self):
return '%s' % self.author.username
author_name.short_description = '作者名称'