📜  django raise 404 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:03.224000             🧑  作者: Mango

代码示例1
from django.http import Http404

def detail(request, poll_id):
    try:
        p = Poll.objects.get(pk=poll_id)
    except Poll.DoesNotExist:
        raise Http404
    return render_to_response('polls/detail.html', {'poll': p})