Answers for "django raise 404"

0

django raise 404

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})
Posted by: Guest on March-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language