내가하지만, 내 tastypie 자원에 대한 아약스 요청을 사용하고 난 SessionAuthentication()하고, 항상 401장고 Tastypie 항상 반환 (401) 무단
resources.py
class EventsResource(ModelResource):
user = fields.ForeignKey(UserResource, 'user')
class Meta:
queryset = Event.objects.all()
resource_name = 'events'
filtering = {'start': ALL,
'end':ALL
}
list_allowed_methods = ['get', 'post','put', 'patch']
detail_allowed_methods = ['get', 'post', 'put', 'delete']
authentication = SessionAuthentication()
authorization = Authorization()
include_resource_uri = True
limit = 0
always_return_data = True
얻을 수 DjangoAuthorization()를 사용하는 경우에도
이것은 캘린더 리소스이므로 이벤트 모델이 있고 내 ajax 요청은 django-admin에로드 된 javascript 파일에 있습니다. 또한 요청 헤더에 csrf 토큰 및 세션 ID가 있는지 확인했지만 작동하지 않습니다.
.ajax({
url: event.resource_uri,
dataType: 'json',
contentType: 'application/json; encode=UTF-8',
type: 'DELETE',
success: function() {
$calendar.fullCalendar('removeEvents');
$calendar.fullCalendar('refetchEvents');
$('#modal-confirm').modal('hide');
showmsg('Evento eliminato correttamente', 'warning');
}
});