Django 找不到我的模板
Django Can't find my template
我发现了很多这样的问题,但是没有人解决这个问题。
当我访问 url
http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
由此 urls.py 路径处理:
path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'),
比我的看法到底returns这个:
I have a view that returns this:
return render(request,'catalog/book_renew_librarian.html', {'form': form, 'bookinst':book_inst})
但我收到模板错误:
TemplateDoesNotExist at /catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
catalog/book_renew_librarian.html
Request Method: GET
Request URL: http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
Django Version: 2.0.3
Exception Type: TemplateDoesNotExist
Exception Value:
catalog/book_renew_librarian.html
Exception Location: C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib\site-packages\django\template\loader.py in get_template, line 19
Python Executable: C:\Users\Araujo\AppData\Local\Programs\Python\Python36\python.exe
Python Version: 3.6.4
Python Path:
['C:\Users\Araujo\Desktop\first_django\locallibrary',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\python36.zip',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\DLLs',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib\site-packages']
Server time: Wed, 14 Mar 2018 19:19:10 +0000
但是我在
中有模板
\catalog\templates\book_renew_librarian.html
如何解决?
您指定路径的目录结构应为:
ProjectFolder
-projectfolder
-catalog
-templates
-catalog
book_renew_librarian.html
-manage.py
我发现了很多这样的问题,但是没有人解决这个问题。
当我访问 url
http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
由此 urls.py 路径处理:
path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'),
比我的看法到底returns这个:
I have a view that returns this:
return render(request,'catalog/book_renew_librarian.html', {'form': form, 'bookinst':book_inst})
但我收到模板错误:
TemplateDoesNotExist at /catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
catalog/book_renew_librarian.html
Request Method: GET
Request URL: http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
Django Version: 2.0.3
Exception Type: TemplateDoesNotExist
Exception Value:
catalog/book_renew_librarian.html
Exception Location: C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib\site-packages\django\template\loader.py in get_template, line 19
Python Executable: C:\Users\Araujo\AppData\Local\Programs\Python\Python36\python.exe
Python Version: 3.6.4
Python Path:
['C:\Users\Araujo\Desktop\first_django\locallibrary',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\python36.zip',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\DLLs',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36',
'C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib\site-packages']
Server time: Wed, 14 Mar 2018 19:19:10 +0000
但是我在
中有模板\catalog\templates\book_renew_librarian.html
如何解决?
您指定路径的目录结构应为:
ProjectFolder
-projectfolder
-catalog
-templates
-catalog
book_renew_librarian.html
-manage.py