modeladmin.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:wagtailcomments 作者: takeflight 项目源码 文件源码
def who(self, comment):
        """
        Who made this comment. If it is a user, link to their profile in the
        admin; otherwise show their name and email address.
        """
        if comment.user:
            user = comment.user
            user_display = user.get_full_name() \
                or getattr(user, user.USERNAME_FIELD)
            try:
                # Just incase someone is running a minimal install without
                # wagtailusers installed.
                return format_html('<a href="{url}">{name}</a>'.format(
                    url=reverse('wagtailusers_users:edit', args=[user.pk]),
                    name=user_display))
            except NoReverseMatch:
                return user_display
        else:
            return '{name} ({email})'.format(name=comment.user_name,
                                             email=comment.user_email)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号