私はビューを持っています。http://127.0.0.1:80/o/token/
に にリクエストを送信します。私は直接ビュー/o/token/
を呼び出して結果を得ることができますか?
そして、それはDjangoビューはリクエストを使わずに別のビューを呼び出す
class GetAccessToken(APIView):
def post(self, request, *args, **kwargs):
msg ={}
return Response(msg, status=status.HTTP_200_OK)
def get_access_token(self, username, password, client_id, client_secret, scope="read write"):
url = "http://127.0.0.1:80/o/token/"
payload = {
'grant_type': 'password',
'username': username,
'password': password,
'scope': scope
}
auth = HTTPBasicAuth(client_id, client_secret)
try:
response = requests.post(url, auth=auth, data=payload, verify=False, timeout=TIMEOUT)
except Exception as err:
print err
の可能な複製を(http://stackoverflow.com/questions/4808329/can-i-call-a -view-within-another-view) – rnevius
私の問題は '' ''/o/token/'' 'は' '' 'django-oauth-toolkit''''からのものです。このビューは '' ''/o/token/'' ''のエントリポイントです。 – user2492364