django.template.exceptions.TemplateDoesNotExist: django/forms/widgets/text.html
django.template.exceptions.TemplateDoesNotExist: django/forms/widgets/number.html
以上报错是pycharm中创建虚拟环境之后把原本自带的templates文件删除,重新在app01下面创建templates用来存放.HTML文件,修改settings.py如下:
解决办法:
找到虚拟环境下的
E:\Djangoitem\Django02\venv\Lib\site-packages\django\forms\templates\django\forms\widgets
根据报错添加内容
text.html
<input type="{{ widget.type }}" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% if widget.attrs.size %} size="{{ widget.attrs.size }}"{% endif %}{% if widget.attrs.maxlength %} maxlength="{{ widget.attrs.maxlength }}"{% endif %}{% if widget.form.auto_id %} id="{{ widget.id_for_label }}"{% endif %}{% if widget.attrs.placeholder %} placeholder="{{ widget.attrs.placeholder }}"{% endif %}{% if widget.attrs.autocomplete %} autocomplete="{{ widget.attrs.autocomplete }}"{% endif %}>
number.html
<input type="{{ widget.type }}" name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% if widget.attrs.min %} min="{{ widget.attrs.min }}"{% endif %}{% if widget.attrs.max %} max="{{ widget.attrs.max }}"{% endif %}{% if widget.attrs.step %} step="{{ widget.attrs.step }}"{% endif %}{% if widget.form.auto_id %} id="{{ widget.id_for_label }}"{% endif %}>
有缘看到的小伙伴,给人家点个赞呗~么么哒❤