提交单选框、时间格式出错

来源:13-4 自定义列表返回数据,同一个model注册两个管理器

桂圆

2018-12-23

老师,我在前端提交日期格式的时候,出错,返回信息个人资料修改失败。如果在form表单中把属性是日期的birthday字段去掉,就不会出问题,请问这是怎么回事呢

class UserView(View):

    def get(self, request):
        user = request.user
        return render(request, 'employee.html', {'user': user})

    def post(self, request):
        user = request.user
        user_profile = get_object_or_404(Employee, user=user)
        user_form = UploadImageForm(request.POST)
        if user_form.is_valid():
            user_profile.name = user_form.cleaned_data['name']
            user_profile.birthday = user_form.cleaned_data['birthday']
            user_profile.moblie = user_form.cleaned_data['moblie']
            user_profile.email = user_form.cleaned_data['email']
            user_profile.save()
            return HttpResponseRedirect(reverse('users:employee'))
        else:
            return HttpResponse('{"status":"fail", "msg":"个人资料修改失败"}', content_type='application/json')
写回答

1回答

bobby

2018-12-24

出错的错误栈截图我看看呢

1
2
bobby
回复
桂圆
好的,
2018-12-26
共2条回复

Python3.6+django+xadmin,打造在线教育平台

【毕设】Python 2.7到3.6 完美适配,Django升级2.0

3677 学习 · 4038 问题

查看课程