为了账号安全,请及时绑定邮箱和手机立即绑定

AttributeError:“str”对象没有属性“get”(django 视图)

AttributeError:“str”对象没有属性“get”(django 视图)

慕的地8271018 2022-12-06 15:33:14
这是ajax操作和django视图之间的通信。有一个表单,如果我点击表单的提交按钮,就会执行 Ajax 代码。但它总是出错,写在下面。我无法弄清楚它的原因。我想这与如何将表单传递给视图有关,但我不知道如何解决。Internal Server Error: /makeeventTraceback (most recent call last):  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner    response = get_response(request)  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response    response = self.process_exception_by_middleware(e, request)  File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response    response = wrapped_callback(request, *callback_args, **callback_kwargs)  File "/workspace/CalendarProject/cencal/views.py", line 42, in makeevent    if form.is_valid():  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 185, in is_valid    return self.is_bound and not self.errors  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 180, in errors    self.full_clean()  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 381, in full_clean    self._clean_fields()  File "/usr/local/lib/python3.7/site-packages/django/forms/forms.py", line 393, in _clean_fields    value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))  File "/usr/local/lib/python3.7/site-packages/django/forms/widgets.py", line 258, in value_from_datadict    return data.get(name)AttributeError: 'str' object has no attribute 'get'
查看完整描述

1 回答

?
慕姐4208626

TA贡献1852条经验 获得超7个赞

尝试 Jsonify 响应字符串。示例:HttpResponse({ "Status": "Successful" })



查看完整回答
反对 回复 2022-12-06
  • 1 回答
  • 0 关注
  • 444 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号