login_required def profile request Профайл пользователя if request use

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@login_required
def profile(request):
"""Профайл пользователя"""
if request.user.is_authenticated():
manip = forms.ProfileForm()
user = request.user
user_profile = request.user.get_profile()
if request.POST:
if request.POST.get('menu', ''):
return HttpResponseRedirect('/account/menu')
manip = forms.ProfileForm(request.POST, request.FILES)
post_data = request.POST.copy()
post_data.appendlist('login', user.username)
if manip.is_valid():
user_profile = manip.save(post_data)
return render_to_response('account/profile.html', {'form' : manip})
# Show current profile settings
profile = UserProfile.objects.get(user__id = user.id)
values = profile.__dict__
values.update(user.__dict__)
form = forms.ProfileForm(initial = values)
return render_to_response('account/profile.html', {'form' : form, 'user' : user})