Use django shortcut for raising 404s.
--- a/pytask/profile/utils.py Sat Jan 15 21:22:56 2011 +0530
+++ b/pytask/profile/utils.py Sat Jan 15 21:23:18 2011 +0530
@@ -1,3 +1,4 @@
+from django import shortcuts
from django.http import Http404
from django.contrib.auth.models import User
from pytask.profile.models import Notification
@@ -35,13 +36,9 @@
def get_user(uid):
- try:
- user = User.objects.get(id=uid)
- except User.DoesNotExist:
- raise Http404
+ user = shortcuts.get_object_or_404(User, pk=uid)
if user.is_active:
return user
else:
raise Http404
-