def profile request if request user is_anonymous return HttpResponseRe

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
def profile(request):
if request.user.is_anonymous():
return HttpResponseRedirect('/')
userprofile = get_object_or_404(OTuser, username = request.user.username)
if request.method == 'POST':
form = ProfileForm(request.POST, request.FILES)
if form.is_valid():
form.update()
else:
print form.errors
else:
form = ProfileForm()
return render_to_response('users/profile.html', {'form': form, 'user': userprofile},
context_instance=RequestContext(request))