OiO.lk Blog python Simple JWT TokenRefreshView: response has two types
python

Simple JWT TokenRefreshView: response has two types


I’m having trouble accessing the data attribute on a Response object in Django Rest Framework after refreshing the access token.

factory = APIRequestFactory()
new_request = factory.post(
"/api/token/refresh/",
{"refresh": refresh_token},
format="json",
)
new_request.META["CONTENT_TYPE"] = "application/json"

refresh_view = TokenRefreshView.as_view()
refresh_response = refresh_view(new_request)
print(type(refresh_response))
refresh_response.data["message"] = "Token refresh successful"

When I run this code, the print statement correctly outputs <class 'rest_framework.response.Response'>.

However, Pylint is complaining that I cannot access the data attribute.
Cannot access attribute "data" for class "HttpResponse" Attribute "data" is unknownPylancereportAttributeAccessIssue



You need to sign in to view this answers

Exit mobile version