django绕过admin登录设置

在admin.py文件添加以下函数
本文是转载:
#绕过admin登录
def allow_anonymous_user():
from django.contrib.auth.models import AnonymousUser
AnonymousUser.id=1
AnonymousUser.pk=1
AnonymousUser.is_active=True
AnonymousUser.is_staff=True
AnonymousUser.is_superuser=True
AnonymousUser.is_authenticated=True
import types
AnonymousUser.has_perm=types.MethodType(lambda self,perm,obj=None: True,AnonymousUser)
AnonymousUser.has_perms=types.MethodType(lambda self,perm_list,obj=None: True,AnonymousUser)
AnonymousUser.has_module_perms=types.MethodType(lambda self,module,obj=None: True,AnonymousUser)
allow_anonymous_user()
上一篇:Ubuntu18.04 从头开始编译 Android Native WebRTC


下一篇:力扣47. 全排列 II