【发布时间】:2015-03-17 16:21:47
【问题描述】:
我有一个通过 ajax 请求调用的视图方法。在请求完成时,我希望用户被重定向到仪表板,但我无法重定向到工作。
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
【问题讨论】:
-
如果您总是想重定向,我想知道您为什么还要使用 Ajax。
标签: django django-1.7