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等等一系列操作之后,终于得偿所愿.可以开工了. 错误 在园子里找了一篇初学者的 ...
随机推荐
- Android 最简单的MVP案例;
随手撸个发出来: V:界面层 //界面层需要实现P.View方法,然后重写P.View中的方法:M层给的数据就在这些个方法的参数中: // 还要获取到P.Provide的实例,使用P.Provide去 ...
- Postgres——pgadmin复制无主键单表至本地数据库
数据库中存在无主键单表gongan_address_all ,需要将余杭区数据导出成另外一张表,因为数据量太大,sql语句效率太差. 通过sql语句查询出余杭区数据,并导出成csv,sql等格式,再导 ...
- Mysql数据表去重
查询不重复元素个数 select count(distinct domain) from black_botnet_domian; 查询表中元素个数大于等于2的元素 SELECT goods_id,g ...
- 装饰器 -- 函数装饰器(tornado异常响应装饰器)
# 值可变,每次使用需要重新赋值 ERR_RESP_TEMPLATE = {"state": "FAILED", "error": None ...
- SpringBoot 之静态资源
boot 的默认的静态资源有多个, 由 ResourceProperties 配置了默认值: private static final String[] CLASSPATH_RESOURCE_LOCA ...
- idea搭建Eureka注册中心
服务的注册与发现 关系调用说明: 服务生产者启动时,向服务注册中心注册自己提供的服务 服务消费者启动时,在服务注册中心订阅自己所需要的服务 注册中心返回服务提供者的地址信息个消费者 消费者从提供者中调 ...
- .NET MVC 控制器和行为
行为就是可访问方法(public) 行为返回类型必须是 ActionResult 或者其派生类,基本上返回类型为以下四种之一 View(视图路径) Json(对象或者对象集合) Content(字符串 ...
- oracle数据链接
using System; using System.Collections.Generic; using System.Data; using System.Data.OracleClient; u ...
- java书籍
1.«java高并发编程详解 »一本比较详细介绍多线程的书籍,个人感觉比 并发编程思想 这本书详细
- Linux常用基础操作命令大全(超实用精心整理)
相信大家都对黑客那种只用命令行对电脑操作的风格惊呆了,其实你也可以做到.linux是一款不同于windows的操作系统,而且它是黑客.渗透人员.运维人员等等必会的.如果你想学习,小编下面整理的命令将会 ...