admin.py 文件源码

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

项目:website 作者: ColonialDevelopment 项目源码 文件源码
def object_link(self, obj):
        object_link = escape(obj.object_repr)
        content_type = obj.content_type

        if obj.action_flag != DELETION and content_type is not None:
            # try returning an actual link instead of object repr string
            try:
                url = reverse(
                      'admin:{}_{}_change'.format(content_type.app_label,
                                                content_type.model),
                        args=[obj.object_id]
                )
                object_link = '<a href="{}">{}</a>'.format(url, object_link)
            except NoReverseMatch:
                pass
            return object_link
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号