from django.db import models

# Create your models here.

from django.contrib.auth.models import User
from django.utils import timezone

#博客文章数据类型
class ArticlePost(models.Model):
	
	# 给model定义元数据
	class Meta:
		# '-created' 返回数据按照创建时间倒序排列
		ordering = ('-created',)

	def __str__(self):
		return self.title

	author = models.ForeignKey(User, on_delete=models.CASCADE)
	title = models.CharField(max_length=100)
	body = models.TextField()
	created = models.DateTimeField(default=timezone.now)
	updated = models.DateTimeField(auto_now=True)
