[Django]-Sending a DELETE request to django-rest with angular is interpreted as OPTIONS

0👍

in fact the problem comes from Django which add a trialing space.
Then when angular tries to get http://test/url but django redirect it to http://test/url/
This redirect imply data loosing.

My solution was to this modification into resource.js file.

Other solutions are possible, Django side with APPEND_SLASH as False

0👍

You may need to adjust your django settings accordingly:

CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = ('127.0.0.1:8000', )

SESSION_COOKIE_DOMAIN = '127.0.0.1'
CSRF_COOKIE_DOMAIN = '127.0.0.1'

also, if you use csrf token, then don’t forget this:

app.run(function($http) {
    $http.defaults.headers.post['X-CSRFToken'] = $.cookie('csrftoken');
});

Leave a comment