accounts/view.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#--accounts/view.py
@login_required
def profile(request):
"""Профайл пользователя"""
if request.user.is_authenticated():
user = request.user
user_profile = request.user.get_profile()
manip = forms.ProfileForm(instance=user_profile)
if request.POST:
if request.POST.get('menu', ''):
return HttpResponseRedirect('/account/menu')
manip = forms.ProfileForm(request.POST, request.FILES, instance=user_profile)
if manip.is_valid():
user_profile = manip.save(request)
return render_to_response('account/profile.html', {'form' : manip})
# Show current profile settings
# profile = UserProfile.objects.get(user__id = user.id)
values = user_profile.__dict__
values.update(user.__dict__)
form = forms.ProfileForm(initial=values)
return render_to_response('account/profile.html', {'form' : form, 'user' : user})
#--profile.html
<form name="registerform" id="registerform" action="#" enctype="multipart/form-data" method="post">
{{ form.as_p }}
<p class="submit">