1
You cannot redirect a user after an ajax request using your backend. The redirect needs to be handled in your ajax call.
In your update view, check if it’s an ajax request. For example, using is_ajax = request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
.
If it’s an ajax request don’t return a redirect but a JsonResponse, such as return JsonResponse({'concept':concept})
.
In your ajax success option, you can then handle the redirect.
success: function(data){
console.log('SUCCESS');
conceptInput.value = '';
definitionInput.value = '';
concept = data['concept'];
redirect_url = #define your redirect url
window.location.replace(redirect_url);
},
Instead of returning the concept value, you can also construct the url in your update view and return it to the ajax call.
Source:stackexchange.com