I have an view method that is called via an ajax request. On request completion I want user to be redirect to the dashboard but I cant get redirect to work.
def apply(request):
if request.is_ajax():
try:
application_type = request.POST['application_type']
if application_type == 'job':
apply_job(request)
elif application_type == 'availability':
apply_availability(request)
return redirect('useraccount_dashboard')
except KeyError:
messages.error(request, 'Request failed!')
return HttpResponseRedirect(reverse_lazy('useraccount_dashboard'))
else:
raise Http404
Return HttpResponse('success')
and make redirect via JavaScript.