views.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:PythonGuru 作者: aronekob34 项目源码 文件源码
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})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号