Skip to content
Browse files

fix DoesNotExist exception.

  • Loading branch information...
1 parent 06d6988 commit 46ddd2dc7de8d8a1c1eea4cfa84c3dd3896800d6 @gkmngrgn gkmngrgn committed Jul 17, 2012
Showing with 6 additions and 7 deletions.
  1. +6 −7 apps/profiles/views.py
View
13 apps/profiles/views.py
@@ -1,12 +1,10 @@
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
+from django.shortcuts import get_object_or_404
from django.utils.decorators import method_decorator
-from django.views.generic import DetailView
-from django.views.generic import ListView
-from django.views.generic import UpdateView
+from django.views.generic import DetailView, ListView, UpdateView
from apps.profiles.forms import ProfileForm
-from apps.profiles.models import City
-from apps.profiles.models import Profile
+from apps.profiles.models import City, Profile
class ProfileList(ListView):
@@ -33,9 +31,10 @@ class ProfileDetail(DetailView):
model = Profile
def get_object(self, queryset=None):
- username = self.kwargs.get('username', '')
+ username = self.kwargs.get('username')
+ user = get_object_or_404(self.model, user__username=username)
- return self.model.objects.get(user__username=username)
+ return user
class ProfileEdit(UpdateView):

0 comments on commit 46ddd2d

Please sign in to comment.
Something went wrong with that request. Please try again.