def has_permission(self, request): is_safe = request.method in rf_permissions.SAFE_METHODS return can_access_admin_site( request.user) and (is_safe or request.user.is_staff)
def confirm_login_allowed(self, user): if not can_access_admin_site(user): return super(CustomAdminAuthenticationForm, self).confirm_login_allowed(user)