Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Throwing a 404 opposed to a 500 when attempting to access an entry th…
Browse files Browse the repository at this point in the history
…at doesn't exist
  • Loading branch information
rossbruniges committed Feb 13, 2013
1 parent d77c579 commit ea98b79
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gameon/submissions/views.py
Expand Up @@ -2,7 +2,7 @@
from django.contrib import messages from django.contrib import messages
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect, Http404
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required


Expand Down Expand Up @@ -79,7 +79,7 @@ def edit_entry(request, slug, template='submissions/edit.html'):


def list(request, category='all', template='submissions/list.html'): def list(request, category='all', template='submissions/list.html'):
page_number = get_page(request.GET) page_number = get_page(request.GET)
if category == 'all': if category == 'all':
entry_set = Entry.objects.all().order_by('-pk') entry_set = Entry.objects.all().order_by('-pk')
page_category = False page_category = False
else: else:
Expand All @@ -97,7 +97,13 @@ def list(request, category='all', template='submissions/list.html'):




def single(request, slug, template='submissions/single.html'): def single(request, slug, template='submissions/single.html'):
# throwing a 404 is MUCH better than a 500 eh?
try:
entry = Entry.objects.get(slug=slug)
except Entry.DoesNotExist:
raise Http404

data = { data = {
'entry': Entry.objects.get(slug=slug), 'entry': entry,
} }
return render(request, template, data) return render(request, template, data)

0 comments on commit ea98b79

Please sign in to comment.