hopieman
hopieman

Reputation: 389

Django Can't find my template

I've found many questions like this but no one have solved this mine.

When I visit the url

http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/

that is handled by this urls.py path:

path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'),

than my view in the end returns this:

I have a view that returns this:

 return render(request,'catalog/book_renew_librarian.html', {'form': form, 'bookinst':book_inst}) 

But I get the template error:

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

But I have the template in the

\catalog\templates\book_renew_librarian.html

How to solve it?

Upvotes: 0

Views: 1279

Answers (1)

Vipin Joshi
Vipin Joshi

Reputation: 302

Your directory structure for the path you specified should be :

ProjectFolder
    -projectfolder
    -catalog
        -templates
            -catalog
                book_renew_librarian.html
    -manage.py

Upvotes: 3

Related Questions