我正在 Apache 上运行一个 Django 站点,该站点以 Nginx 实例为前端,为我的静态媒体提供服务。
我通过 django-tastypie 将 API 暴露给需要修补字段的模型。当我进行本地测试(通过 django runserver)时,一切都按预期工作。然而,在实时服务器上,我收到返回的“400(错误请求)”。
我看过一些地方说Nginx不支持PATCH?是对的吗?有没有一个好的解决方法?难道我做错了什么?
我只通过我想要更新的字段发送postData.
jQuery 代码:
$.ajax({url: '...',
type: 'PATCH',
accepts: 'application/json',
contentType: 'application/json',
dataType: 'json',
data: postData,
processData: false,
success: function() {
// Success Code!
},
error: function() {
// Error Code!
}
});
美味派资源:
class ReceivedMessageResource(ModelResource):
"""
"""
campaign = fields.ForeignKey(CampaignResource, 'campaign')
campaign_name = fields.CharField(readonly=True)
campaign_id = fields.IntegerField(readonly=True)
message_type = fields.CharField(readonly=True)
display_date = fields.CharField(readonly=True)
attachments = fields.ToManyField('apps.campaign.api.AttachmentResource',
'attachment_set',
related_name='message',
full=True)
class Meta:
queryset = ReceivedMessage.objects.all()
resource_name = 'message'
filtering = {'id': ALL,
'campaign': ALL_WITH_RELATIONS}
excludes = ['reason', 'provider', 'loyalty_profile', 'original_message', 'date_received']
allowed_methods = ['get', 'post', 'put', 'delete', 'patch']
paginator_class = ReceivedMessagesPaginator
authentication = ApiKeyAuthentication()
authorization = DjangoAuthorization()
任何有关如何对此进行排序的指示将不胜感激:)