1. James Bennett
  2. django-profiles
  3. Issues
Issue #2 resolved

Profile Detail to edit if profile doesn't exist

Anonymous created an issue

I wanted to be able to show the profile link, but didn't want to have a dynamic link to check if they already had a profile created. So in the profile detail function, I added

try:
    profile_obj = user.get_profile()
except ObjectDoesNotExist:

if request.user.username == username and request.user.is_authenticated():

return HttpResponseRedirect(reverse('profiles_create_profile'))

raise Http404

To check to see if the user is logged in, and is browsing to his user, if it doesn't exist, move him to create one.

Comments (1)

  1. Log in to comment