Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. def uadmin_myprofile_update(request):
  2.     user = User.objects.get(id=request.user.id)
  3.     user_id = request.user.id
  4.     print('User id: %s, %s' % (user_id, user))
  5.     if request.method == 'POST':
  6.         user_form = UserForm(request.POST, instance=request.user)
  7.         profile_form = ProfileForm(request.POST, instance=request.user.profile)
  8.         if user_form.is_valid() and profile_form.is_valid():
  9.             user_form.save()
  10.             profile_form.save()
  11.             return render(request, 'uadmin/uadmin_myprofile.html')
  12.         else:
  13.             print('')
  14.     else:
  15.         user_form = UserForm(request.POST, instance=request.user)
  16.         profile_form = ProfileForm(instance=request.user.profile)
  17.  
  18.     args = {
  19.         'user_form': user_form,
  20.         'profile_form': profile_form,
  21.     }
  22.     return render(request, 'uadmin/uadmin_myprofile_update.html', args)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement