【发布时间】:2020-05-27 03:59:11
【问题描述】:
我正在尝试“轻量级 Django_ 使用 REST、Websockets 和 Backbone [Elman & Lavin 2014-11-13]”中提到的这个项目,但在这个项目中,当我找不到我的模板时,我被卡住了,任何人都可以帮助解决这个问题
我的设置是
import os
import sys
from django.conf import settings
DEBUG = os.environ.get('DEBUG', 'on') == 'on'
SECRET_KEY = os.environ.get('SECRET_KEY',
'%jv_4#hoaqwig2gu!eg#^ozptd*a@88u(aasv7z!7xt^5(*i&k')
ALLOWED_HOSTS = []
BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
settings.configure(
DEBUG=DEBUG,
SECRET_KEY=SECRET_KEY,
ALLOWED_HOSTS=ALLOWED_HOSTS,
ROOT_URLCONF=__name__,
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
),
INSTALLED_APPS=(
'django.contrib.staticfiles',
),
TEMPLATE_DIRS=(
os.path.join(BASE_DIR, 'templates'),
),
STATICFILES_DIRS=(
os.path.join(BASE_DIR, 'static'),
),
STATIC_URL='/static/',
)
我的观点是
def index(request):
example = reverse('placeholder', kwargs={'width': 50, 'height':50})
context = {
'example': request.build_absolute_uri(example)
}
return render(request, 'home.html', context)
#and urls are
urlpatterns = (
url(r'^image/(?P<width>[0-9]+)x(?P<height>[0-9]+)/$', placeholder,
name='placeholder'),
url(r'^$', index, name='homepage'),
)
我在文件夹中的模板顺序是
- foo
- templates
- home.html
- static
- site.css
【问题讨论】:
-
可以分享一下错误信息吗?
标签: python html django web backend