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.
25 lines
609 B
25 lines
609 B
from django.db import models |
|
from django.utils import timezone |
|
from django.contrib.auth.models import User |
|
|
|
|
|
# 博客文章 model |
|
class Article(models.Model): |
|
# 作者 |
|
author = models.ForeignKey( |
|
User, |
|
null=True, |
|
on_delete=models.CASCADE, |
|
related_name='articles' |
|
) |
|
# 标题 |
|
title = models.CharField(max_length=100) |
|
# 正文 |
|
body = models.TextField() |
|
# 创建时间 |
|
created = models.DateTimeField(default=timezone.now) |
|
# 更新时间 |
|
updated = models.DateTimeField(auto_now=True) |
|
|
|
def __str__(self): |
|
return self.title
|
|
|