주재팍
20
2021-01-14 19:06:30
2
103

django, drf rest-auth 1주일 넘게 씨름중입니다.ㅠㅠ


settings.py

INSTALLED_APPS = [
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'django.contrib.sites',

  # drf, rest_auth, allauth
  'rest_framework',
  'rest_framework.authtoken',
  'rest_auth',
  'allauth',
  'allauth.account',
  'allauth.socialaccount',
  'rest_auth.registration',

  # apps    
  'board_subject_restful',
  ]

REST_FRAMEWORK = {
  'DEFAULT_PERMISSION_CLASSES': [
    'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
  ],

  'DEFAULT_AUTHENTICATION_CLASSES': [
    'rest_framework.authentication.SessionAuthentication',
    'rest_framework.authentication.TokenAuthentication',
  ]
  }

SITE_ID = 1

urls.py

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api-auth/', include('rest_framework.urls')),
    path('', include('board_subject_restful.urls')),
    path('rest-auth/', include('rest_auth.urls')),
    path('rest-auth/registration/', include('rest_auth.registration.urls')),
]



rest-auth/ 경로로 접속하면 아래와 같이 404에러가 뜨네요


rest-auth 모든 api endpoint가 저 상태입니다 ㅠㅠ 

스택오버플로에도 물어봣는데 답을 못찾았어요

0
  • 답변 2

  • createA
    78
    2021-01-14 19:33:10
    rest_auth.urls 파일도 보여주시겠어요?
  • 주재팍
    20
    2021-01-14 20:24:22 작성 2021-01-15 18:02:18 수정됨

    createA 


    아 그리고 위에 urls.py에 api-auth/도 똑같은 증상으로 안되네요 ㅠㅠ


    rest-auth.urls.py

      1 from django.conf import settings
      2 from django.urls import path
      3
      4 from dj_rest_auth.views import (LoginView, LogoutView, PasswordChangeView,
      5                                 PasswordResetConfirmView, PasswordResetView,
      6                                 UserDetailsView)
      7
      8 urlpatterns = [
      9     # URLs that do not require a session or valid token
     10     path('password/reset/', PasswordResetView.as_view(), name='rest_password_reset'),
     11     path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
     12     path('login/', LoginView.as_view(), name='rest_login'),
     13     # URLs that require a user to be logged in with a valid session / token.
     14     path('logout/', LogoutView.as_view(), name='rest_logout'),
     15     path('user/', UserDetailsView.as_view(), name='rest_user_details'),
     16     path('password/change/', PasswordChangeView.as_view(), name='rest_password_change'),
     17 ]
     18
     19 if getattr(settings, 'REST_USE_JWT', False):
     20     from rest_framework_simplejwt.views import TokenVerifyView
     21
     22     from dj_rest_auth.jwt_auth import get_refresh_view
     23
     24     urlpatterns += [
     25         path('token/verify/', TokenVerifyView.as_view(), name='token_verify'),
     26         path('token/refresh/', get_refresh_view().as_view(), name='token_refresh'),
     27     ]


  • 로그인을 하시면 답변 을 등록할 수 있습니다.