0
点赞
收藏
分享

微信扫一扫

用LCD循环右移显示“Welcome to China“

大师的学徒 2024-01-02 阅读 7
django

blog

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

class Post(models.Model):

    STATUS_CHOICES = (

        ('draft','Draft'),

        ('published','Published')

    )

    title = models.CharField(max_length=250)

    slug = models.SlugField(max_length=250,unique_for_date='publish')

    author = models.ForeignKey(User,on_delete=models.CASCADE,related_name='blog_post')

    body = models.TextField()

    publish = models.DateTimeField(default=timezone.now)

    created = models.DateTimeField(auto_now_add=True)

    updated = models.DateTimeField(auto_now=True)

    status = models.CharField(max_length=10,choices=STATUS_CHOICES,default='draft')


    class Meta:

        ordering = ('-publish',)


    def __str__(self):

        return self.title

https://docs.djangoproject.com/en/2.0/ref/models/fields/ 可以找到所有字段类型。

举报

相关推荐

0 条评论