【发布时间】:2021-05-12 10:25:51
【问题描述】:
我正在使用 Django ASGI 服务器并正在发送一个发布请求,但它没有响应。 在邮递员中不断显示“发送请求” 我的意见.py
@csrf_exempt
def test(Request):
if Request.method == "POST":
response=requests.post('http://localhost:8000/api/token/')
return HttpResponse(response)
我的 urls.py
urlpatterns = [
path('', include('chat.urls')),
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls')),
path('api/token/', jwt_views.TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/token/refresh/', jwt_views.TokenRefreshView.as_view(), name='token_refresh'),
]
【问题讨论】:
-
我建议将 print 放在视图 test() 中,以验证它是否被调用,并在 'if' 子句中进行验证。