登陆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 错误处理的更多相关文章

  1. django.template.exceptions.TemplateDoesNotExist: login.html报错

    前言 在某一次按以前的步骤使用Django    “django.template.exceptions.TemplateDoesNotExist: login.html”错误,在以为是html文件出 ...

  2. django.template.exceptions.TemplateDoesNotExist: rest_framework/api.html

    django.template.exceptions.TemplateDoesNotExist: rest_framework/api.html setting文件中的 INSTALLED_APPS加 ...

  3. Django 找不到模版报错" django.template.exceptions.TemplateDoesNotExist: index.html"

    解决办法:在setting.py的TEMPLATES‘DIRS'[]加入模版路径 os.path.join(BASE_DIR, 'templates') TEMPLATES = [ { 'BACKEN ...

  4. django.template.exceptions.TemplateDoesNotExist: index.html

    django.template.exceptions.TemplateDoesNotExist: index.html 在网上查了下,setting中 TEMPLATES 的 'DIRS' 需要添加o ...

  5. django找不到模板的错误处理django.template.exceptions.TemplateDoesNotExist: blog/list.html

    错误提示如下图: 程序出错对于程序员而言是最常见的,一般解决的要点是看清错误提示(读懂英文很重要) 根据错误提示 blog\list.html这个文件不存在,也就是没找到资源 这个时候需要去检查有没有 ...

  6. 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 ...

  7. 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 ...

  8. Django 自定义模板标签 报错django.template.exceptions.TemplateSyntaxError: '####' is not a registered tag library. Must be one of:

    我写代码遇到这个错误,但是发现程序没有写错,好像是程序有缓存,重新运行几次就好了. 自定义模板标签,可以不用写views,url直接通过自定义函数把变量传给模板. 具体实现: 1.在app下新建Pyt ...

  9. pythoncharm 中解决启动server时出现 “django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured”的错误

    背景介绍 最近,尝试着用pythoncharm 这个All-star IDE来搞一搞Django,于是乎,下载专业版,PJ等等一系列操作之后,终于得偿所愿.可以开工了. 错误 在园子里找了一篇初学者的 ...

随机推荐

  1. Linux背背背(1)

    目录: 1.文件目录 2.基本语法 3.centos7之后的版本中查看ip地址 4.~ 5.修改时间 ------------------------------------------------- ...

  2. mysql六种日志

    错误日志 MySQL服务启动和关闭过程中的信息以及其它错误和警告信息.默认在数据目录下 普通查询日志 用于记录select查询语句的日志.general_log.general_log_file 默认 ...

  3. python使用 openpyxl包 excel读取与写入

    '''### 写入操作 ###from openpyxl import Workbook#实例化对象wb=Workbook()#创建表ws1=wb.create_sheet('work',0) #默认 ...

  4. 某大型跨境电商JVM调优总结

    前提:某大型跨境电商业务发展非常快,线上机器扩容也很频繁,但是对于线上机器的运行情况,特别是jvm内存的情况,一直没有一个统一的标准来给到各个应用服务的owner.经过618大促之后,和运维的同学讨论 ...

  5. linux 查看端口被占用

    linux 查看端口被占用 1.lsof  -i : 端口号 用于查看某一端口的占用情况,比如查看8080端口使用情况,lsof  -i:8080 如果执行 lsof  -i:8080 系统提示 :  ...

  6. 英文文档帮查&翻译计划

    以CSDN为首,知乎其次,cnblog带路的一大批博客上充斥着大量低质量的编程入门教程,代码粗制滥造,毫无缩进,没有高亮,东抄西抄.初学者如果长期参照这种垃圾博客来解决问题,将会适得其反,走入歧途. ...

  7. Elasticsearch **代码片段

    ```JAVA BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery(); RangeQueryBuilder createTimeQuery ...

  8. maven项目发布到tomcat的错误

    Could not publish to the server. java.lang.IndexOutOfBoundsException "Updating status for Tomca ...

  9. JAVA程序调试

    调试 步骤1:设置断点(不能在空白处设置断点) 步骤2:启动调试 步骤3:调试代码(F6单步跳过)笔记本Fn+F6(F5) 步骤4:结束调试 掌握调试的好处? l  很清晰的看到,代码执行的顺序 l  ...

  10. CDialogEx::OnPaint()的问题,或者为什么在对话框程序的OnPaint中绘图无效的问题

    这是一个基于对话框的程序,对话框上有按钮,还有几个CStatic用来绘图,之前都是好好的,今天改成Unicode版本后,编译正常,运行时CStatic中的图像怎么也不显示,有时候会闪现一次就消失,问题 ...