Created
September 3, 2020 19:27
-
-
Save AtufaShireen/7a9333956a7eec5c1f1a783132c4a7ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .forms import UserUpdateForm,ProfileUpdateForm | |
@login_required | |
def profile(request): | |
if request.method == 'POST': | |
p_form = ProfileUpdateForm(request.POST,request.FILES,instance=request.user.profile) | |
u_form = UserUpdateForm(request.POST,instance=request.user) | |
if p_form.is_valid() and u_form.is_valid(): | |
u_form.save() | |
p_form.save() | |
messages.success(request,'Your Profile has been updated!') | |
return redirect('profile') | |
else: | |
p_form = ProfileUpdateForm(instance=request.user) | |
u_form = UserUpdateForm(instance=request.user.profile) | |
context={'p_form': p_form, 'u_form': u_form} | |
return render(request, 'users/profile.html',context ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment