【发布时间】:2016-02-25 05:31:59
【问题描述】:
这个错误是什么意思?我正在导入from django.shortcuts import render, Http404, HttpResponseRedirect
,但为什么不能使用 HttpResponseRedirect?我读了回溯,但那里没有什么用处......
这是我的代码
@login_required
def read(request, id):
try:
next = request.GET.get('next', None)
notification = Notification.objects.get(id=id)
if notification.recipient == request.user:
notification.read = True
notification.save()
if next is not None:
return HttpResponseRedirect(next)
else:
return HttpResponseRedirect(reverse("notifications_all"))
else:
raise Http404
except:
raise HttpResponseRedirect(reverse("notifications_all"))
我不明白错误的含义,有人可以向我解释我做错了什么吗?
【问题讨论】: