Answer the question
In order to leave comments, you need to log in
Why might django not see the template located in the correct folder?
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.app_directories.Loader: b:\learning_log\learning_logs\templates\users\register.html (Source does not exist)
django.template.loaders.app_directories.Loader: b:\learning_log\users\templates\users\register.html (Source does not exist)
django.template.loaders.app_directories.Loader: B:\learning_log\ll_env\lib\site-packages\django\contrib\admin\templates\users\register.html (Source does not exist)
django.template.loaders.app_directories.Loader: B:\learning_log\ll_env\lib\site-packages\django\contrib\auth\templates\users\register.html (Source does not exist)
Traceback (most recent call last):
File "B:\learning_log\ll_env\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "B:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "B:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "b:\learning_log\users\views.py", line 24, in register
return render(request, 'users/register.html', context)
File "B:\learning_log\ll_env\lib\site-packages\django\shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "B:\learning_log\ll_env\lib\site-packages\django\template\loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "B:\learning_log\ll_env\lib\site-packages\django\template\loader.py", line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: users/register.html
[27/Apr/2020 19:21:40] "GET /users/register/ HTTP/1.1" 500 80525
[27/Apr/2020 19:37:26] "GET /topics/ HTTP/1.1" 200 434
[27/Apr/2020 19:37:29] "GET /users/login/ HTTP/1.1" 200 835
[27/Apr/2020 19:37:31] "POST /users/login/ HTTP/1.1" 302 0
[27/Apr/2020 19:37:31] "GET / HTTP/1.1" 200 238
[27/Apr/2020 19:37:32] "GET /topics/ HTTP/1.1" 200 396
[27/Apr/2020 19:37:33] "GET / HTTP/1.1" 200 238
[27/Apr/2020 19:37:51] "GET /users/logout/ HTTP/1.1" 200 319
Internal Server Error: /users/register/
Traceback (most recent call last):
File "B:\learning_log\ll_env\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "B:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "B:\learning_log\ll_env\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "b:\learning_log\users\views.py", line 24, in register
return render(request, 'users/register.html', context)
File "B:\learning_log\ll_env\lib\site-packages\django\shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "B:\learning_log\ll_env\lib\site-packages\django\template\loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "B:\learning_log\ll_env\lib\site-packages\django\template\loader.py", line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: users/register.html
Answer the question
In order to leave comments, you need to log in
It's just Matiz asshole, made a bunch of typos in the code - in his book. But on the other hand, I had to google a lot and hard for many non-working pieces of code from the book, but I remembered it forever. Maybe this is some kind of author's move)
If you use a book published by Peter then they have a typo.
In "Peter's" users/views.py file , the last line looks like this:
return render(request, ' users /register.html', context)
And in the original it looks like this:
return render(request, ' registration /register.html ', context)
After specifying the correct path, all files function.
PS: It's better to always keep the original handy ;)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question