Use django shortcut for raising 404s.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Sat, 15 Jan 2011 21:23:18 +0530
changeset 420 920fb0dcc384
parent 419 0bf7c07ef922
child 421 89a61c582f39
Use django shortcut for raising 404s.
pytask/profile/utils.py
--- 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
-