django raise 404

Solutions on MaxInterview for django raise 404 by the best coders in the world

showing results for - "django raise 404"
Adrián
03 Apr 2019
1from django.http import Http404
2
3def detail(request, poll_id):
4    try:
5        p = Poll.objects.get(pk=poll_id)
6    except Poll.DoesNotExist:
7        raise Http404
8    return render_to_response('polls/detail.html', {'poll': p})
9