Django에서 편하게 RESTAPI 구현을 돕는 프레임워크인 DRF(Django-Rest-Framework)
또 DRF에서 로그인을 편하게 구현하기위한 라이브러리인 dj_rest_auth 에서 JWT(JSON 웹 토큰)
을 구현하는중 자꾸 오류가 났다.
※ django-rest-auth 가 아닌 dj_rest_auth 이다.
※ django-rest-auth 는 프로젝트 중단됨
프로젝트를 진행중 오류라기는 커녕 JWT 사용이 아예 되지 않는것이였는데.
많은 검색 결과
setting.py 파일
REST_AUTH 안에 'USE_JWT': True 를 사용해 주어야 한다고 한다.
기존 방법은
REST_USE_JWT = True
만 넣어주면 잘 동작이 되었었는데 2023년도 2월 업데이트부터 바뀌였다고한다.
이것말고도 세팅부분에서 바뀐게 조금 있는것같다.
https://dj-rest-auth.readthedocs.io/en/latest/configuration.html#use-jwt
Configuration — dj-rest-auth 3.0.0 documentation
TOKEN_SERIALIZER The path to the serializer class for the Token response on successful authentication in dj_rest_auth.views.LoginView. The value is the dotted path to dj_rest_auth.serializers.TokenSerializer, which is also the default. JWT_SERIALIZER The p
dj-rest-auth.readthedocs.io
늘 최신버전은 옳지만,,
뻘짓한 내시간....
또한 예제
https://krakensystems.co/blog/2020/custom-users-using-django-rest-framework
Custom users using Django REST framework | Kraken Systems Ltd.
The built-in Django User model follows the pattern consisted of username, email and password. In this tutorial you will learn to RESTfully simplify it to just email and password.
krakensystems.co
이것을 진행할 때 ugettext_lazy 오류가 나는데
gettext_lazy 로 바꾸면 정상 작동 된다.
'Dev > Web' 카테고리의 다른 글
Firebase 파이썬으로 DB 데이터 가져오기 (0) | 2023.09.06 |
---|---|
Firebase 파이썬으로 DB 데이터 삽입 (0) | 2023.09.06 |
Django db 연결 (0) | 2023.04.18 |