异常类型:TemplateDoesNotExist 登录模板不存在

时间:2021-07-10 18:17:01

标签: python django

<块引用>

TemplateDoesNotExist at /login/login.html 请求方法:GET 请求 URL: http://localhost:8000/login/ Django 版本: 3.2.5 异常 类型:TemplateDoesNotExist 异常值:login.html 异常 位置:C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader.py, 第 19 行,在 get_template Python 中 可执行文件:C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\python.exe Python 版本:3.7.0 Python 路径:
['C:\Users\LISHITHA\virl\logp', 'C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\python37.zip', 'C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\DLLs', 'C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\lib', 'C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32', 'C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\lib\site-packages'] 服务器时间:2021 年 7 月 10 日星期六 18:20:58 +0000 模板加载器 事后 Django 尝试按以下顺序加载这些模板:

使用引擎 django:

django.template.loaders.filesystem.Loader: C:\Users\LISHITHA\virl\logp\templates\login.html(源不 存在)django.template.loaders.app_directories.Loader: C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\admin\templates\login.html (来源不存在) django.template.loaders.app_directories.Loader: C:\Users\LISHITHA\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\contrib\auth\templates\login.html (来源不存在)

    from django.urls import path
    from . import views
    
    urlpatterns=[
        path('',views.home,name='home'),
        path('register/',views.register,name='register'),
        path('login/',views.login,name='login'),
    ]
   
    
    from django.shortcuts import render
    from django.http import HttpResponse,JsonResponse
    from django.urls import path
    
    def home(request):
        return HttpResponse('welcome home')
    def register(request):
        return render(request,'register.html') 
    def login(request):
        return render(request,'login.html')   

并在那个空的粘贴起始模板中声明登录模板

    'DIRS': [os.path.join(BASE_DIR, 'templates')],

http://localhost:8000/login/#

0 个答案:

没有答案
相关问题