Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django模板不存在execpt home url_Python_Django_Python 3.x_Django Templates_Virtualenv - Fatal编程技术网

Python django模板不存在execpt home url

Python django模板不存在execpt home url,python,django,python-3.x,django-templates,virtualenv,Python,Django,Python 3.x,Django Templates,Virtualenv,我正在创建一个简单的网站。有一个奇怪的错误模板没有在/about/上显示,但是我的主页运行良好,没有临时错误。我将home.html和about.html放在同一个目录中并尝试了许多解决方案 实际的问题是一个URL正在工作,而另一个则不工作。请帮帮我,谢谢 TemplateDoesNotExist at /about/ about.hmtl Request Method: GET Request URL: https://www.appname./about/ Django V

我正在创建一个简单的网站。有一个奇怪的错误
模板没有在/about/
上显示,但是我的
主页
运行良好,没有临时错误。我将
home.html
about.html
放在同一个
目录中
并尝试了许多解决方案 实际的问题是一个URL正在工作,而另一个则不工作。请帮帮我,谢谢

TemplateDoesNotExist at /about/

about.hmtl

Request Method:     GET
Request URL:    https://www.appname./about/
Django Version:     2.2.9
Exception Type:     TemplateDoesNotExist
Exception Value:    

about.hmtl

Exception Location:     /home/name/virtualenv/appname/3.5/lib/python3.5/site-packages/django/template/loader.py in get_template, line 19
Python Executable:  /home/name/virtualenv/appname/3.5/bin/python3.5_bin
Python Version:     3.5.7
Python Path:    

['/home/name/appname',
 '/opt/passenger-5.3.7-4.el6.cloudlinux/src/helper-scripts',
 '/home/name/virtualenv/appname/3.5/lib64/python35.zip',
 '/home/name/virtualenv/appname/3.5/lib64/python3.5',
 '/home/name/virtualenv/appname/3.5/lib64/python3.5/plat-linux',
 '/home/name/virtualenv/appname/3.5/lib64/python3.5/lib-dynload',
 '/opt/alt/python35/lib64/python3.5',
 '/opt/alt/python35/lib/python3.5',
 '/home/name/virtualenv/appname/3.5/lib/python3.5/site-packages']

Server time:    Sun, 3 May 2020 04:48:46 +0000

Template-loader postmortem

Django tried loading these templates, in this order:

Using engine django:

    django.template.loaders.app_directories.Loader: /home/name/virtualenv/appname/3.5/lib/python3.5/site-packages/django/contrib/admin/templates/about.hmtl (Source does not exist)
    django.template.loaders.app_directories.Loader: /home/name/virtualenv/appname/3.5/lib/python3.5/site-packages/django/contrib/auth/templates/about.hmtl (Source does not exist)
    django.template.loaders.app_directories.Loader: /home/name/appname/mysite/templates/about.hmtl (Source does not exist)


我的模板

应用程序

应用程序


setting.py

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',
            ],
        },
    },
]

您在“关于视图”中的
视图.py
文件中有一个输入错误。拼写
about.html
而不是
about.hmtl
。 就这样;)

您编写了about.hmtl而不是html…请更正:)

from django.shortcuts import render
from django.http import HttpResponse

def homepage(request):
    return render(request=request,template_name='home.html')

def about(request):
    return render(request=request,template_name='about.hmtl')
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import path
from . import views

app_name = "bugengine"

urlpatterns = [
    url(r'^$', views.homepage, name="homepage"),
    url(r'^about/',views.about, name="about"),
]
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',
            ],
        },
    },
]