我正在构建一个 Django-Tastypie 服务器。创建资源成功后,服务器会回复“201 created”,但是Content-Type是text/html
. 我希望资源始终返回 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"