首页 Django项目开发与部署视频教程 模型字段开发演示和注意事项
pay pay

模型字段开发演示和注意事项

日期: 六月 25, 2023, 9:46 a.m.
阅读: 76
作者: Python自学网-村长

摘要: 模型字段开发演示和注意事项

模型字段开发演示和注意事项

class Art(models.Model):
    """title/short_title/keyword/description/text/click/del/tail/time/tag/img/top_list/author/recommend/top"""
    art_title = models.CharField(max_length=200, verbose_name='文章标题')
    art_short_title = models.CharField(max_length=200, verbose_name='文章副标题', blank=True)
    art_keyword = models.CharField(max_length=60, verbose_name='文章关键词', blank=True)
    art_description = models.CharField(max_length=254, verbose_name='文章描述', blank=True)
    art_text = RichTextUploadingField(verbose_name='文章正文')
    art_click = models.IntegerField(default=0, verbose_name='点击数')
    art_tail = models.CharField(max_length=60, verbose_name='网址后缀')
    art_time = models.DateTimeField(auto_now_add=True, verbose_name='发布时间')
    art_tag = models.ManyToManyField(to='Tags', blank=True, verbose_name='标签')
    art_img = models.ImageField(upload_to='', blank=True, null=True, verbose_name='图片上传')
    art_top_list = models.ForeignKey(to=Art_List, verbose_name='所属列表', on_delete=models.DO_NOTHING)
    art_author = models.CharField(max_length=60, verbose_name='作者')
    art_recommend = models.BooleanField(default=False, verbose_name='推荐')
    art_top = models.BooleanField(default=False, verbose_name='置顶')
    art_del = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.art_title

    class Meta:
        db_table = 'article'
        ordering = ['-id']
        verbose_name = '文章'
        verbose_name_plural = verbose_name
class Page(models.Model):
    """title/keyword/description/text/click/del/tail"""
    page_title = models.CharField(max_length=200, verbose_name='标题')
    page_keyword = models.CharField(max_length=200, verbose_name='关键词', blank=True)
    page_description = models.CharField(max_length=240, verbose_name='描述', blank=True)
    page_text = RichTextUploadingField(verbose_name='正文')
    page_tail = models.CharField(max_length=80, verbose_name='网址后缀', unique=True)
    page_click = models.IntegerField(default=0, verbose_name='点击数')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    def __str__(self):
        return self.page_title

    class Meta:
        db_table = 'page'
        ordering = ['-id']
        verbose_name = 'page页面'
        verbose_name_plural = verbose_name

 

原创视频,版权所有,未经允许,切勿转载,违者必究!
回顶部