django.template.exceptions.TemplateDoesNotExist: login.html 错误处理
登陆Login界面时候报错
Internal Server Error: /login/
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.6/site-packages/django/core/handlers/exception.py", line , in inner
response = get_response(request)
File "/usr/local/python3/lib/python3.6/site-packages/django/core/handlers/base.py", line , in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/python3/lib/python3.6/site-packages/django/core/handlers/base.py", line , in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/python/project/MyCrazyeyes/web/views.py", line , in login
return render(request, 'login.html')
File "/usr/local/python3/lib/python3.6/site-packages/django/shortcuts.py", line , in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/usr/local/python3/lib/python3.6/site-packages/django/template/loader.py", line , in render_to_string
template = get_template(template_name, using=using)
File "/usr/local/python3/lib/python3.6/site-packages/django/template/loader.py", line , in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: login.html
[/Feb/ ::] "GET /login/?next=/ HTTP/1.1"
在setting.py下DIRS如下所示
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
在setting.py重新设置下DIRS如下所示,则问题解决
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'DIRS': [],
'DIRS': ["%s/%s" %(BASE_DIR,'templates'),],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
另外需要确保templates目录下确实是有login.html文件
[python@qinhan templates]$ pwd
/home/python/project/MyCrazyeyes/templates
[python@qinhan templates]$ ls
login.html
[python@qinhan templates]$
django.template.exceptions.TemplateDoesNotExist: login.html 错误处理的更多相关文章
- django.template.exceptions.TemplateDoesNotExist: login.html报错
前言 在某一次按以前的步骤使用Django “django.template.exceptions.TemplateDoesNotExist: login.html”错误,在以为是html文件出 ...
- django.template.exceptions.TemplateDoesNotExist: rest_framework/api.html
django.template.exceptions.TemplateDoesNotExist: rest_framework/api.html setting文件中的 INSTALLED_APPS加 ...
- Django 找不到模版报错" django.template.exceptions.TemplateDoesNotExist: index.html"
解决办法:在setting.py的TEMPLATES‘DIRS'[]加入模版路径 os.path.join(BASE_DIR, 'templates') TEMPLATES = [ { 'BACKEN ...
- django.template.exceptions.TemplateDoesNotExist: index.html
django.template.exceptions.TemplateDoesNotExist: index.html 在网上查了下,setting中 TEMPLATES 的 'DIRS' 需要添加o ...
- django找不到模板的错误处理django.template.exceptions.TemplateDoesNotExist: blog/list.html
错误提示如下图: 程序出错对于程序员而言是最常见的,一般解决的要点是看清错误提示(读懂英文很重要) 根据错误提示 blog\list.html这个文件不存在,也就是没找到资源 这个时候需要去检查有没有 ...
- django.template.exceptions.TemplateSyntaxError: 'article_tags' is not a registered tag library.
django.template.exceptions.TemplateSyntaxError: 'article_tags' is not a registered tag library. Must ...
- django.template.exceptions.TemplateSyntaxError: 'static' is not a registered tag library. Must be one of:
在访问web页面时报错,详细日志如下: django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registere ...
- Django 自定义模板标签 报错django.template.exceptions.TemplateSyntaxError: '####' is not a registered tag library. Must be one of:
我写代码遇到这个错误,但是发现程序没有写错,好像是程序有缓存,重新运行几次就好了. 自定义模板标签,可以不用写views,url直接通过自定义函数把变量传给模板. 具体实现: 1.在app下新建Pyt ...
- pythoncharm 中解决启动server时出现 “django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured”的错误
背景介绍 最近,尝试着用pythoncharm 这个All-star IDE来搞一搞Django,于是乎,下载专业版,PJ等等一系列操作之后,终于得偿所愿.可以开工了. 错误 在园子里找了一篇初学者的 ...
随机推荐
- Vue todolist练习 知识点
1.localStorage的用法总结 (1).这儿是什么:局部存储器.它是html5新增的一个本地存储API,所谓localStorage就是一个小仓库的意思,它有5M的大小空间,存储在浏览器中,我 ...
- dubbo 支持的7种协议
建议看原文 转自:https://blog.csdn.net/xiaojin21cen/article/details/79834222 1.dubbo 协议 (默认) 2.rmi 协议 3.hes ...
- Eclipse关于怎么调出web project
myeclipse和eclipse两个软件不一样的点很多,当然玩的时候也会遇到找不到的选项 此片摘自: https://www.cnblogs.com/icebutterfly/p/7771936.h ...
- Linux权限管理之ACL权限
注:转载自:https://www.cnblogs.com/ysocean/p/7801329.html 目录 1.什么是 ACL 权限? 2.查看分区 ACL 权限是否开启:dump2fs ①.查看 ...
- React琐碎
1 dangerouslySetInnerHTML 使用此属性的原因是得到一个安全的数据,生成一个仅包含唯一key——__html的对象,表明这段内容会被当成text/taint使用,它的使用方式是这 ...
- Myeclipse版本引发的css样式问题:头部自动生成一行代码导致样式引入不成功
在运行新的项目之后,发现样式全部没了 利用开发者模式查看原因:是因为css样式文件的顶部自动生成了一行代码导致的 生成的代码:[genuitec-file-id="wc2-7"], ...
- C#//字节数组转16进制字符串
//字节数组转16进制字符串 private static string byteToHexStr(byte[] bytes,int length) { string returnStr = &quo ...
- ubuntu安装jdk,maven,tomcat
ubuntu16.04安装jdk8 -jdk 检查是否安装成功 java -version 出现如上信息即安装成功 安装maven,先去官网下载指定版本的maven,个人使用apache-maven- ...
- jquery即时获取上传文件input file文件名
截图: 代码: <input type="file" id="choosefile" style="display:none"/& ...
- sqlserver truncate清空表时候,无法删除 'B表',因为该表正由一个 FOREIGN KEY 约束引用。
外键: 查询:select object_name(a.parent_object_id) 'tables' from sys.foreign_keys a where a.referenced_ ...