定义一个名称为Article的model,里面有如下六个字段:文章图片地址(img)、文章标题(title)、文章内容(content)、浏览量(views)、点赞量(likes)、创建日期(createtime):
from django.db import models
class People(models.Model):
name = models.CharField(null=True,blank=True,max_length=200)
job = models.CharField(null=True,blank=True,max_length=200)
def __str__(self):
return self.name
class Aritcle(models.Model):
headline = models.CharField(null=True,blank=True,max_length=500)
content = models.CharField(null=True,blank=True,max_length=200)
def __str__(self):
return self.headline
# Create your models here.
class Comment(models.Model):
name = models.CharField(max_length=50)
avatar = models.CharField(max_length=250)
content = models.TextField(null=True, blank=True)
createtime = models.DateField(auto_now=True)
def __str__(self):
return self.content
网友评论