Commit ffa7b38cbb258e39d7ecbb8961952fc9948f7a8e
1 parent
566ca7a7
Exists in
master
and in
39 other branches
Fixing get statement to raise a 404 if it doesn't exist
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
src/super_archives/views.py
| ... | ... | @@ -16,7 +16,7 @@ from django.utils.translation import ugettext as _ |
| 16 | 16 | from django.core.exceptions import ObjectDoesNotExist |
| 17 | 17 | from django.utils.decorators import method_decorator |
| 18 | 18 | from django.contrib.auth.decorators import login_required |
| 19 | -from django.shortcuts import render, redirect | |
| 19 | +from django.shortcuts import render, redirect, get_object_or_404 | |
| 20 | 20 | |
| 21 | 21 | from haystack.query import SearchQuerySet |
| 22 | 22 | |
| ... | ... | @@ -30,8 +30,8 @@ class ThreadView(View): |
| 30 | 30 | |
| 31 | 31 | def get(self, request, mailinglist, thread_token): |
| 32 | 32 | |
| 33 | - thread = Thread.objects.get(subject_token=thread_token, | |
| 34 | - mailinglist__name=mailinglist) | |
| 33 | + thread = get_object_or_404(Thread, subject_token=thread_token, | |
| 34 | + mailinglist__name=mailinglist) | |
| 35 | 35 | thread.hit(request) |
| 36 | 36 | |
| 37 | 37 | try: | ... | ... |