'TemplateDoesNotExist at /' Error in django? - python

The server is working fine, however while using extend for this 'home.html' file unable to link the template :
In 'home.html':
{ % extends "/template1/personal/header.html" % }
While loading localhost:
Django tried loading these templates, in this order:
`Using engine django:
django.template.loaders.app_directories.Loader: /usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/ffgg/home.html (Source does not exist).
django.template.loaders.app_directories.Loader: /usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/ffgg/home.html (Source does not exist)`

1) Check what is in TEMPLATE_DIRS Variable in settings.py. That is the folder Django looks up in every app in order to find your template.
2) Try remove the leading slash:
{% extends 'template1/personal/header.html' %}
3) if template1 is in TEMPLATE_DIRS, then 'app/template.html' would be enough
{% extends 'personal/header.html' %}
Read on:
https://tutorial.djangogirls.org/en/template_extending/
https://docs.djangoproject.com/en/1.7/topics/templates/

Related

TemplateSyntaxError at /en/admin/login/ 'staticfiles' is not a registered tag library. Must be one of:

I've installed django-cms. The first time I type python manage.py runserver, I get the error
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_style_tags
admin_tree
admin_tree_list
admin_urls
cache
cms_admin
cms_alias_tags
cms_js_tags
cms_static
cms_tags
djangocms_text_ckeditor_tags
easy_thumbnails_tags
filer_admin_tags
filer_image_tags
filer_tags
i18n
l10n
log
menu_tags
sekizai_tags
snippet_tags
static
thumbnail
tz
All the solutions basically say the same thing: Use {% load static %} instead of {% load staticfiles %}
I changed the files where these errors occurred....and it worked! I get the django CMS page saying that installation was successful.
But now it also says that "the form could not be loaded. Please check that the server is running correctly." This message displays after I log in with "admin" as username and password (which somehow was created for me) on the localhost. And yes, the server is running correctly. No issues
Could it be that the edits I did changed some of the files? I only changed the static files as I was supposed to in the solutions on this site.
That's due to deprecations, as mentioned in Django TemplateSyntaxError - 'staticfiles' is not a registered tag library
It's already logged as an issue against django-cms here https://github.com/divio/django-cms/issues/6844
In the meantime
pipenv install 'django<2.1'
(or pip, if that's your pref) will get you going.

Django template not found but file exist

I have some third-part library, templates from that library is diplayed by default.
I want to replace layout template, from which all other start inheritance.
So, in my local app I create new layout.html file, which contents
{% extends 'library:layout.html' %}
But in that case I've got
TemplateDoesNotExist at /test-url/
test.html
But still Template-loader postmortem display, that it can find file:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/path/to/app/templates/test.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/path/to/library/app1/templates/test.html (File does not exist)
/path/to/library/app2/templates/test.html (File does not exist)
/path/to/library/app3/templates/test.html (File exists)
So, in library app3 Django found template, but for some reason do not use it. Can you help with this issue?
Thanks.
Make sure that there isn't another missing template that is causing the error.
Your extends tag looks wrong. I would expect to see library/layout.html, not library:layout.html
{% extends 'library/layout.html' %}

Template loader doesn't find /registration/password_reset_form.html

I am having a strange issue using the built in password_rest view of django(1.8). In the documentation they say that the template name defaults to registration/password_reset_form.html. Keeping that in mind, I didn't give any template name in my urls.py, thinking that django will load the default template.Here is my url for the password reset
urls.py
url(r'^password_reset$', auth_views.password_reset, name='password_reset'),
When I click the forgot password link,
<p><a href={% url 'password_reset' %}> Forgot your password?</a></p>
which executes the password_rest view, I am getting Template DoesNotExist error and below is the error message
TemplateDoesNotExist at /accounts/password_reset
registration/password_reset.html
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/vinothkumar/github/djtest/templates/registration/password_reset.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/home/vinothkumar/github/djtest/venv_new/lib/python3.4/site-packages/django/contrib/admin/templates/registration/password_reset.html (File does not exist)
/home/vinothkumar/github/djtest/venv_new/lib/python3.4/site-packages/django/contrib/auth/templates/registration/password_reset.html (File does not exist)
/home/vinothkumar/github/djtest/accounts/templates/registration/password_reset.html (File does not exist)
my question is why the template loader is looking for /registration/password_reset.html instead of loading the default /registration/password_reset_form.html?
I tried the same approach for password_reset_done, in this case it loads the default template /registration/password_reset_done.html. and everything there works fine.

Django 1.7 Changed name of template now TemplateDoesNotExist Error

So I changed the name of my registration template from user_form.html to register.html. I've also changed it in the urls.py file to reflect the new name, however when I try to go to the register page I get the following:
Exception Type: TemplateDoesNotExist
Exception Value:web/user_form.html
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
../swl/root/lib/pythpy2.7.egg/django/contrib/admin/templates/web/user_form.html (File does not exist)
../django/contrib/auth/templates/web/user_form.html (File does not exist)
../templates/web/user_form.html (File does not exist)
..tastypie/templates/web/user_form.html (File does not exist)
../bootstrap3/templates/web/user_form.html (File does not exist)
../web/templates/web/user_form.html (File does not exist)
Why would the template loader still be looking for the old filename?
edit: this is my url for register:
url(r'register/?$',
UserCreate.as_view(),
{
'template_name':'accounts/register.html'
},
name = 'register'),
Try to replace all user_form.html to registration.html in all files. You can use Find/replace in files feature (or something similar) of your text editor or IDE.
Change url to:
url(r'register/?$',
UserCreate.as_view(template_name='accounts/register.html'),
name = 'register')
The class-based views will attempt to use a default template name when no name is explicitly declared. (The CreateView uses (appname)/(model)_form.html) Your choices are:
Name your template using the default name
Specify the template in the URL (as in Vladimir's answer)
Specify the template name in the view code like so:
class UserCreate(CreateView):
template_name = "accounts/register.html"
Hope this helps
Restart the apache server.
For Ubuntu server 20:
/etc/init.d/apache2 restart

TemplateDoesNotExist (Django)

I am trying to load a register template for my first django site,
I put register.html file in /home/Desktop/projects/purple/purple/templates/registration.html
here but there is a error that is say to there is no file I did not understant that's why? can anyone have a idea?
Request Method: GET
Request URL: http...:127.0.0.1:8000/registration/
Django Version: 1.4
Exception Type: TemplateDoesNotExist
Exception Value: registration.html
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/Desktop/projects/purple/purple/templates/registration.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/registration.html (File does not exist)
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/registration.html (File does not exist)
Using loader django.template.loaders.eggs.Loader:
Given that the exception copy and pasted refers to:
/home/Desktop/projects/purple/purple/templates/registration.html
and can't find it... all of your problems lie in whether or not registration.html exists at the directory.
There are 2 possibilities:
File doesn't exist
cd into that exact directory and find out if it does.
Permissions
ls -lh /home/Desktop/projects/purple/purple/templates/registration.html
Make sure it's readable.
chmod 644 /home/Desktop/projects/purple/purple/templates/registration.html
do you have Registration directory inside Template directory??
if so then include this is your settings.py .
TEMPLATE_DIRS = (
BASE_DIR +'/Templates',
BASE_DIR +'/registration',
)
Because django is looking for registration.html in your Template directory instead of /template/registration.
see the order you mentioned in the question. watch the path.

Categories