- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
Python 2.7 和 Django 1.10我的模板存在,但我做错了!
TemplateDoesNotExist at /basicview/2/
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TEST</title>
</head>
<body>
This is template_two view!
</body>
</html>
Request Method: GET
Request URL: http://127.0.0.1:8000/basicview/2/
Django Version: 1.10.1
Exception Type: TemplateDoesNotExist
Exception Value:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TEST</title>
</head>
<body>
This is template_two view!
</body>
</html>
Exception Location: /home/i/djangoenv/local/lib/python2.7/site-packages/Django-1.10.1-py2.7.egg/django/template/loader.py in get_template, line 25
Python Executable: /home/i/djangoenv/bin/python
Python Version: 2.7.11
Python Path:
['/home/i/djangoenv/bin/firstapp',
'/home/i/djangoenv/lib/python2.7',
'/home/i/djangoenv/lib/python2.7/plat-i386-linux-gnu',
'/home/i/djangoenv/lib/python2.7/lib-tk',
'/home/i/djangoenv/lib/python2.7/lib-old',
'/home/i/djangoenv/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-i386-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/home/i/djangoenv/local/lib/python2.7/site-packages',
'/home/i/djangoenv/local/lib/python2.7/site-packages/Django-1.10.1-py2.7.egg',
'/home/i/djangoenv/lib/python2.7/site-packages',
'/home/i/djangoenv/lib/python2.7/site-packages/Django-1.10.1-py2.7.egg']
Server time: Пт, 23 Сен 2016 15:43:30 +0000
settings.py(os.path.join(BASE_DIR)、'templates' 或/home/mainapp/templates)不工作..
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['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',
],
},
},
]
article/views.py 我的 def 看起来像:
def template_two(request):
view = "template_two"
t = get_template('myview.html')
html = t.render(Context({'name': view}))
return render(request, html, {})
我的文件:
mainapp/mainapp/settings.py
mainapp/mainapp/article/views.py
mainapp/templates/myview.html
最佳答案
我建议您将模板放入您的应用中。
您的文件将在此处:
mainapp/mainapp/templates/myview.html
请确保将 mainapp
添加到您的 INSTALLED_APPS
中,如下所示:
INSTALLED_APPS = [
...
'mainapp',
]
关于python - TemplateDoesNotExist 但它存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39665105/
我正在使用 Django 3.0.7 并有一个名为 starling 的项目和一个名为 piggybank 的应用程序。我将 index.html 放在 piggybank 目录中的 template
我有一个看起来很常见的初学者问题。 我正在处理我的第一个 django 项目,当我设置 View 时,出现“TemplateDoesNotExist”错误。 我现在花了很多时间在这上面 - 我知道有很
我可以使用“py manage.py runserver”运行我的服务器,不会出现任何错误,然后我的登录页面出现,我登录到系统,当我单击该页面中的 customer_list 链接时,主欢迎页面会显示
我有以下目录: 项目 模板<-- base.html 位于此处 用户<--应用程序 -- 用户/模板 <-- profile.html 位于此处 profile.html 扩展了 base.html。
我使用的是 Python 3.5 和 Django 1.9。我知道我在某个地方犯了一个愚蠢的错误,但我似乎无法找到它,关于错误可能在哪里的任何帮助? View.py from django.short
Python 2.7 和 Django 1.10我的模板存在,但我做错了! TemplateDoesNotExist at /basicview/2/ TEST This
我正在尝试呈现一个简单的页面,但我遇到了一个问题。 TemplateDoesNotExist at /pages/ {} 找不到模板文件夹。这是我对 settings.py 的配置 BASE_DIR
重要数据: Ubuntu 11.04 Django 1.3.1 我正在运行由 Whoosh 支持的 Haystack。网站的其余部分功能正常,但当我尝试搜索时,我得到一个 TemplateDoesNo
出错了 views.py: def index(request): user = request.user return render(request, 'main_a
我在尝试在 django 中渲染模板时收到此错误: 模板不存在 ... Template-loader postmortem Django tried loading these templates,
我在尝试在 django 中渲染模板时收到此错误: 模板不存在 ... Template-loader postmortem Django tried loading these templates,
我正在尝试在 django 中渲染模板。当我连接到该网站时出现此错误: django.template.loaders.filesystem.Loader: path-to-azerty/templa
我有一个像这样的django实践 │ manage.py ├─accounts │ │ models.py │ │ tests.py │ │ urls.py │ │ views.py
错误 我正在尝试使用 django-nested-inline包裹。似乎一切正常,但是当我尝试使用管理网站创建新的 Course 时,出现以下错误: TemplateDoesNotExist at /
我知道这个网站上有很多关于这个问题的问题,但我找不到解决方案。 我在 Windows 10 上使用 Python 3.6 (anaconda) + django 2.0.2。 我正在学习教程:http
我被这个问题困住了。我在这里和谷歌上检查了很多建议,但没有办法摆脱这个错误。 似乎 Django 没有检查 app/templates/* 目录。它应该自动检查,不是吗? 我的settings.py:
我一直在试用 Django 教程 Django Tutorial Page 3并遇到了这个错误 "TemplateDoesNotExist at /polls/ " . 我假设问题出在我的代码指向模板
我正在使用获取模板的路径 paymenthtml = os.path.join(os.path.dirname(__file__), 'template\\payment.html') 并在另一个应用
我是Django新手,按照Django官方文档就可以了,但是这里有个问题。 我用 创建了一个新的 Django 项目 Django 1.8.2 + PyCharm 4.5.1 + Python 3.4
我正在尝试在 Django 管理中创建自定义小部件。我创建了一个类: class FroalaWYSIWYGTextareaWidget(django.forms.widgets.Textarea):
我是一名优秀的程序员,十分优秀!