我在加载Django视图时遇到问题。 FYI很新的Django)Django视图无法从项目文件夹加载
是我得到的错误是TemplateDoesNotExist在/调查/
Django是从 “异常位置 ” 加载/用户/姓名/蟒蛇/ ENVS/Django的/lib/python2.7/site-packages/django/template/loader.py”
应该从加载 “/Users/NAME/Documents/Django/template/index.html”
我在我的APP view.py
return render(request,'index.html')
我的settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ["/Users/NAME/Documents/Django/template/"],
我如何从我的项目文件的视图加载?
文件结构
total 0
drwxr-xr-x 6 NAME staff 204 11 Aug 16:17 Django
drwxr-xr-x 6 NAME staff 204 26 Jun 23:17 test
./Django:
total 32
drwxr-xr-x 10 NAME staff 340 11 Aug 16:17 Django
-rw-r--r-- 1 NAME staff 12288 10 Aug 21:09 db.sqlite3
-rwxr-xr-x 1 NAME staff 804 10 Aug 21:08 manage.py
drwxr-xr-x 15 NAME staff 510 11 Aug 16:17 polls
./Django/Django:
total 56
-rw-r--r-- 1 NAME staff 0 10 Aug 21:08 __init__.py
-rw-r--r-- 1 NAME staff 147 10 Aug 21:09 __init__.pyc
-rw-r--r-- 1 NAME staff 3160 11 Aug 10:14 settings.py
-rw-r--r-- 1 NAME staff 2648 11 Aug 10:14 settings.pyc
-rw-r--r-- 1 NAME staff 176 10 Aug 21:24 urls.py
-rw-r--r-- 1 NAME staff 402 10 Aug 21:25 urls.pyc
-rw-r--r-- 1 NAME staff 390 10 Aug 21:08 wsgi.py
-rw-r--r-- 1 NAME staff 603 10 Aug 21:09 wsgi.pyc
./Django/polls:
total 80
-rw-r--r-- 1 NAME staff 0 10 Aug 21:19 __init__.py
-rw-r--r-- 1 NAME staff 146 10 Aug 21:25 __init__.pyc
-rw-r--r-- 1 NAME staff 128 10 Aug 21:19 admin.py
-rw-r--r-- 1 NAME staff 150 10 Aug 21:19 apps.py
drwxr-xr-x 3 NAME staff 102 10 Aug 21:19 migrations
-rw-r--r-- 1 NAME staff 122 10 Aug 21:19 models.py
-rw-r--r-- 1 NAME staff 264 10 Aug 21:43 models.pyc
drwxr-xr-x 3 NAME staff 102 10 Aug 21:40 templates
-rw-r--r-- 1 NAME staff 125 10 Aug 21:19 tests.py
-rw-r--r-- 1 NAME staff 116 10 Aug 21:23 urls.py
-rw-r--r-- 1 NAME staff 326 10 Aug 21:25 urls.pyc
-rw-r--r-- 1 NAME staff 184 11 Aug 15:56 views.py
-rw-r--r-- 1 NAME staff 483 11 Aug 15:56 views.pyc
错误页面通常显示Django试图从中加载模板的文件夹。 –
请显示你的'Django/polls/templates'目录和子目录的布局。 – Alasdair
嘿家伙,对于迟到的回复感到抱歉。周末我在办公室离开了电脑。 克劳斯D.见下文 使用引擎的Django: 'django.template.loaders.app_directories.Loader:/Users/NAME/anaconda/envs/Django/lib/python2.7/site-packages/django/contrib/ admin/templates/index.html(来源不存在)' 'django.template.loaders.app_directories.Loader:/Users/NAME/anaconda/envs/Django/lib/python2.7/site-packages/django/contrib /auth/templates/index.html(来源不存在) ' 麦金太尔 /用户/名/文件/ Django的/ Django的/调查/模板 它只是在它 –