我在 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()
任何关于如何排序的方向都将不胜感激:)