django admin 内容过长 截取加省略号

    def short_content(self):
        if len(str(self.content)) > 1000:
            return '{}...'.format(str(self.content)[0:1000])
        else:
            return str(self.content)
    short_content.allow_tags = True

然后在list_display中定义相关的标签方法

    但是不能解决verbose_name失效的问题

 

posted @ 2020-03-12 14:21  spidernyp  阅读(331)  评论(1编辑  收藏  举报