You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Django runserver报错:无法解析关键字'date_created'为字段

解决Django FieldError字段名不匹配问题

问题核心

报错信息明确显示:

django.core.exceptions.FieldError: Cannot resolve keyword 'date_created' into field. Choices are: content, data_created, id, title

这说明你在entries_detail.html、entries_list.html模板以及views.py视图文件中使用的字段名date_created,和模型里实际定义的字段名data_created不一致,导致Django无法识别该字段。

修复方法

  • 定位错误字段:遍历entries_detail.html、entries_list.html和views.py,找出所有使用date_created的代码位置
  • 统一替换字段名:将所有date_created替换为模型中正确的data_created
  • 重启服务:重新执行python manage.py runserver,验证报错是否消除

内容的提问来源于stack exchange,提问作者Strangers

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 13:05:53