2017-12-31 59 views
0

에 대한 응답 데이터를 가져 오는 방법을 나는과 같이 로그인 테스트를 실행 해요 :장고 테스트 - 향후 사용을

{ 
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6ImV2YW4iLCJleHAiOjE1MTQ2NzYzNTYsImVtYWlsIjoiZXZhbkAyOGJlYXR0eS5jb20iLCJvcmlnX2lhdCI6MTUxNDY3Mjc1Nn0.8CfhfgtMLkNjEaWBfNXbUWXQMZG4_LIru_y4pdLlmeI", 
    "user": { 
     "pk": 2, 
     "username": "test", 
     "email": "[email protected]", 
     "first_name": "", 
     "last_name": "" 
    } 
} 
:

def test_login_user(self): 
    client = APIClient() 
    url = reverse('rest_login') 
    data = { 
     'username': 'test', 
     'password': 'Welcome2' 
    } 
    response = self.client.post(url, data) 
    self.assertEqual(response.status_code, status.HTTP_200_OK) 
    client.logout() 

내가 응용 프로그램에 로그인하면 일반적으로 나는이 같은 JSON 리턴를 참조

나중에 사용할 수 있도록 token 값을 가져올 수 있기를 원하지만 response에는 data 값을 가져 오지 못하는 것 같습니다. 내가 무엇을 찾고

답변

관련 문제