def user_profile(request, username):
    user = get_object_or_404(User, username=username)
    edit = request.GET.get('edit')

    # Only the owner of the profile can change it. We use a regular Form rather
    #  than a ModelForm because some fields belong to User and other fields
    #  belong to UserProfile.
    form_error = False
    if request.method == 'POST' and request.user.id == user.id:
        form = UserProfileForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data    # Easier to write.
            user.first_name = data.get('first_name')
            user.last_name = data.get('last_name')
            user.email = data.get('email')
            user.profile.affiliation = data.get('affiliation')
            user.profile.location = data.get('location')
            user.profile.bio = data.get('bio')    # Assings to bio.raw.
            user.profile.share_email = data.get('share_email')
            user.profile.resolver_institution = data.get('resolver_institution')
            user.save()
            user.profile.save()
        else:
            form_error = True

    comments = Comment.objects.filter(created_by=user).order_by('-created_on')
    context = RequestContext(request, {
        'active': '',
        'username': user.username,
        'full_name': '%s %s' % (user.first_name, user.last_name),
        'is_staff': user.is_staff,
        'email': user.email,
        'profile': user.profile,
        'usercomments': comments,
    })

    # User has elected to edit their own profile.
    if edit and user.id == request.user.id:
        # This template has an almost identical layout to userprofile.html,
        #  except that display fields are replaced with input fields.
        template = loader.get_template('isisdata/userprofile_edit.html')
        form = UserProfileForm(initial={
            'first_name': user.first_name,
            'last_name': user.last_name,
            'email': user.email,
            'affiliation': getattr(user.profile, 'affiliation', None),
            'location': getattr(user.profile, 'location', None),
            'bio': user.profile.bio.raw,    # Raw markdown.
            'share_email': user.profile.share_email,
            'resolver_institution': user.profile.resolver_institution,
        })
        context.update({'form': form})
    elif form_error:
        context.update({'form': form})
        template = loader.get_template('isisdata/userprofile_edit.html')
    else:
        template = loader.get_template('isisdata/userprofile.html')
    return HttpResponse(template.render(context))
Each user has a profile page that displays some basic information about
dataset/ETHPy150Open upconsulting/IsisCB/isiscb/isisdata/views.py/user_profile