def edit_profile(request):
try:
if request.method == 'GET':
account_form = forms.EditAccountForm(instance=request.user.account)
if request.user.account.account_type == 'Individual':
del account_form.fields['business_name']
elif request.method == 'POST':
account_form = forms.EditAccountForm(request.POST, instance=request.user.account)
if account_form.is_valid():
account_form.save()
return HttpResponseRedirect(reverse('account:view-profile'))
except ObjectDoesNotExist:
logger.error('No account profile found for user {}'.format(request.user))
return HttpResponseServerError()
return render(request, 'account/edit_profile.html', {'account_form': account_form})
评论列表
文章目录