def retrieve(request): try: profile = request.user.get_profile() except UserProfile.DoesNotExist: profile = UserProfile(user=request.user) profile.save() return profile
def retrieve(request): """ gets the UserProfile instance for a user, creates one if it does not exist """ try: profile = request.user.get_profile() except UserProfile.DoesNotExist: profile = UserProfile(user=request.user) profile.save() return profile
def retrieve(request): '''note that this requires an authenticated user before we try calling it''' try: profile = request.user.get_profile() except UserProfile.DoesNotExist: profile = UserProfile(user = request.user) profile.save() return profile