0
我正在構建一個Django-Tastypie服務器。在我成功創建資源後,服務器將響應我「201創建」,但Content-Type爲text/html
。我想要資源總是返回JSON響應,該怎麼做?如何成功創建資源後創建JSON響應?
這裏是我的資源代碼
class UserResource(ModelResource):
class Meta:
resource_name = "user"
queryset = User.objects.all()
authentication = Authentication()
authorization = Authorization()
allowed_methods=["post"]
fields= ["username","email","id"]
def determine_format(self, request):
return "application/json"
非常感謝你 – user1687717