
[英]Django Rest Framework resource doesn't respond to request with invalid token
[英]Django, Postman. Why the GET request doesn't respond with my API?
我正在本地开发并尝试查看我的 API 的视图(非编程术语)。 我的观点(编程术语)看起来像:
class WeaponDetailsView(DetailView):
model = Weapon
template_name = 'weapons/weapon/details.html'
我也尝试通过脚本获得响应:
import requests
url = 'http://127.0.0.1:8000/'
res = requests.get(url).json()
print(res)
但这给了我raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
错误。
那么为什么我不能只看到我的 API,而不是 html 正文内容?
为什么当我使用 Django Rest 框架实现 API 视图时情况会发生变化? 我的意思是它只返回 grate 的 API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.