【发布时间】:2018-08-07 13:08:28
【问题描述】:
我的views.py中有这个
def read_file(request):
f = open('path/text.txt', 'r')
file_contents = f.read()
print (file_contents)
f.close()
return render(request, "index.html", context)
网址.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^impala/$', views.people, name='impala'),
]
我在网站上没有看到任何内容(text.txt 文件包含信息)。 我在 nohup 中没有看到任何打印输出。 没有错误
【问题讨论】:
-
您的
urls.py中有什么内容?此外,您没有定义context。这使我假设您没有将基于函数的视图连接到路线。 -
@YannicHamann 请参阅编辑。我的模板中也有 base.html,我在 index.html 中继承
标签: python django python-2.7