我有一个在Linux服务器上运行的django项目(通过digitalocean)
我遇到的问题很特殊,一切正常,但是模板和views.py
文件之间的通信似乎无法正常工作。
例如:
应用名称为“ gaapp”
如果我在<h1>This heading is to test if changes to the templates are picked up</h1>
文件中添加了gaapp/templates/gaapp/dash.html
,则它可以成功运行(我可以在网站上看到标题)
但是如果我添加变量<h2>This {{variable}} should show on the site</h2>
,则什么也没有显示。
有什么想法吗?
myprojectdir / gaapp / urls.py:
#!/usr/bin/env python3
from django.urls import path
from . import views
urlpatterns = [
path("", views.dash, name='dash'),
path("pages", views.pages, name='pages'),
path('users/', views.users, name='users'),
]
myprojectdir / gaapp / views.py:
bunch of imports
def dash(request):
variable = "This is the variable that should be displayed, as in the example"
return render(request, 'gaapp/dash.html',
{"variable": variable})
已编辑:
我还没有触摸过模板的设置。