13👍
You must use absolute paths in the TEMPLATE_DIRS
setting.
Convenient thing to do, at the top of your settings, insert:
import os
DIRNAME = os.path.abspath(os.path.dirname(__file__))
Then anywhere you use a path, use os.path.join
.
Example, your TEMPLATE_DIRS
would become:
TEMPLATE_DIRS = (
os.path.join(DIRNAME, 'site-templates/'),
)
40👍
I was faced to the same problem. The mistake in my case was, that the ‘app’ was not in the INSTALLED_APPS
list at the project settings.py file.
The error raise an error message they suggests similar error.
line 25, in get_template TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: authControll/index.html
settings.py –> Application definition
INSTALLED_APPS = [
...,
'authControll'
]
- How can I disable a model field in a django form
- Django model inheritance and type check
- Django render_to_string() ignores {% csrf_token %}
- Is there any list of blog engines, written in Django?
6👍
Django has a sort of patterns and philosophy. Try to use the same configurations other wise you have to change the core patterns in django.
The pattern for templates in django are like this:
polls/templates/polls/index.html
But to use it you have to add the installed app at the configs:
INSTALLED_APPS = [
'polls.apps.PollsConfig', #<-- Here this shoud be solve it
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',]
For more information look at:
https://docs.djangoproject.com/en/3.0/intro/tutorial02/#activating-models
- Is exposing a session's CSRF-protection token safe?
- All the values of the many to many field : Django
1👍
My mistake was simply bad positioning:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'histories',
]
My solution was :
INSTALLED_APPS = [
'histories',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
- Logout Django Rest Framework JWT
- Is there a command for creating an app using cookiecutter-django?
- Creation of dynamic model fields in django
0👍
This will surely solve the issue, instead of all the above try adding only below line in settings.py
:
TEMPLATE_DIRS = (
"appname/templates",
)
- Have a url that accepts all characters
- Django create new user without password
- How to embed matplotlib graph in Django webpage?
- Difference between self.request and request in Django class-based view
-6👍
http://docs.djangoproject.com/en/1.2/ref/templates/api/#loading-templates
Small fix for @zsquare answer:
import os
DIRNAME = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = ( DIRNAME+'/site-templates/' )
- In django, is there a way to directly annotate a query with a related object in single query?
- How to add attributes to option tags?