admin.py 文件源码

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

项目:django-cms-articles 作者: misli 项目源码 文件源码
def find_users(self, request, queryset):
        for author in queryset.all():
            if author.user:
                continue

            try:
                author.user = User.objects.get(username=author.login)
            except User.DoesNotExist:
                pass

            if not author.user:
                author.user = User.objects.filter(email=author.email).first()

            if not author.user:
                author.user = User.objects.filter(first_name=author.first_name, last_name=author.last_name).first()

            if author.user:
                author.save()
                self.message_user(
                    request,
                    _('Successfully found user {} for author').format(author.user, author),
                    messages.SUCCESS)
            else:
                self.message_user(request, _('Failed to find user for author {}').format(author), messages.ERROR)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号