djagno authenticate 함수 오류

행행·2022년 9월 15일
0
  • 우선 django 공식 문서에서 authenticate의 설명을 보자

authenticate(request, username=None, password=None, **kwargs)
Tries to authenticate username with password by calling User.check_password. If no username is provided, it tries to fetch a username from kwargs using the key CustomUser.USERNAME_FIELD. Returns an authenticated user or None.

request is an HttpRequest and may be None if it wasn’t provided to authenticate() (which passes it on to the backend).

  • 나같은 경우는 계속해서 user = authenticate(email = email) 의 값이 계속 none이였다.

  • 찾아보니 해결책이 많지 않았다.

  • 결국 찾게된 문제 해결법은 다음과 같다.

  • model에서 is_active 컬럼이 있는 경우 이를 true로 해줘야 인증이 된다.

  • 나는 is_active = models.BooleanField(default=False) 로 해놨어서 authenticate 함수가 계속 none을 return했다.

profile
성장하려고 분투 중인 개발자

0개의 댓글