Python中文
首页
教程
问答
标签
搜索
登录
注册
无法在Django应用程序中显示html文件
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>在我的<code>views.py</code>文件中,我现在有这个</p> <pre><code>from django.contrib import messages from django.http import HttpResponse from django.core.urlresolvers import reverse from django.shortcuts import redirect, get_object_or_404, render from django.views.generic import ListView, DetailView from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic.base import View, TemplateView from models import * from forms import * class test(TemplateView): def test(request): return HttpResponse("test") def get_template_names(self): return ["myapp/test.html"] </code></pre> <p><code>urls.py</code></p> <pre><code>from django.conf.urls import patterns, url from views import test urlpatterns = patterns('', url(r'$', test.as_view(), name='test'), ) </code></pre> <p><code>test.html</code></p> <pre><code>{% extends "index.html" %} {% block content %} <P> HELLO </P> {% endblock %} </code></pre> <p>除了网站加载时什么都没有显示!你知道吗</p> <p>那个索引.html文件加载很好,因为我加载的html文件正在扩展它。但当我点击连接到中的url“test”的按钮时网址.py没有更新。这个文本.html文件中只有文本“hello world”。你知道吗</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>试着这样写你的观点:</p> <pre><code>class Test(TemplateView): template_name = "myapp/test.html" </code></pre> <p>这是设置模板名称的推荐方法。你知道吗</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在Excel中读取公式并将其转换为Python中的计算?
1 回答
如何在excel中读取嵌入的excel,并将嵌入文件中的信息存储在主excel文件中?
1 回答
如何在Excel中返回未知列长度的非空顶行列值?
6 回答
如何在excel中选择数据列?
6 回答
如何在Excel中通过脚本自动为一列中的所有单元格创建公共别名
10 回答
如何在excel中高效格式化范围AttributeError:“tuple”对象没有属性“fill”
7 回答
如何在excel单元格中编写python函数
10 回答
如何在excel单元格中自动执行此python代码?
5 回答
如何在excel工作表中创建具有相应值的新列
3 回答
如何在Excel工作表中复制条件为单元格颜色的python数据框?
8 回答
如何在Excel工作表中循环
10 回答
如何在excel工作表中打印嵌套词典?
1 回答
如何在excel工作表中绘制所有类的继承树?
6 回答
如何在Excel工作表中自动调整列宽?
8 回答
如何在excel工作表中追加并进一步处理
7 回答
如何在excel工作表之间进行更改?
8 回答
如何在excel或csv上获取selenium数据?
7 回答
如何在Excel或Python中将正确的值赋给正确的列
2 回答
如何在excel或python中提取单词周围的文本?
3 回答
如何在excel或python中转换来自Jira的3w 1d 4h的fromat数据?
1 回答