18👍
Add to settings.py
from os.path import join
TEMPLATE_DIRS = (
join(BASE_DIR, 'templates'),
)
5👍
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
Add this to settings.py
. In django 1.6 BASE_DIR
is defined. Otherwise define BASE_DIR
as
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
- South migrate error: name 'UUID' is not defined
- Redirect management.call_command() stdout to a file
- How do I reply to an email using the Python imaplib and include the original message?
- 'instancemethod' object has no attribute '__getitem__'
3👍
According to Django tutorial, you should add
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
to your settings.py file (so it is a list
not a tuple
)
- How to get a model object using model name string in Django
- Tag inside tag in django template
- How can you use two different versions of Django for different projects on the same machine?
- How to create new resource with foreign key in TastyPie
2👍
It should be
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
Or you might see an error like this :
DeprecationWarning: The TEMPLATE_DIRS setting must be a tuple. Please
fix your settings, as auto-correction is now deprecated.
self._wrapped = Settings(settings_module)
For django >= 1.6 it is a tuple
1👍
Use the below given code snippet. Paste it in last of the settings.py file.
from os.path import join
TEMPLATE_DIRS = (
join(BASE_DIR, 'templates'),
)
Here BASE_DIR
means your project directory, not the inner directory where the settings.py resides. Create a directory named “templates” (without quotes) inside the BASE_DIR
and store your templates inside that directory. Django will join templates directory to the BASE_DIR
using os.path.join()
function. Hope this helps.
- Is there a way to access the context from everywhere in Django?
- ERROR: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock'
- How to kill all instance of uwsgi
- Can we use serializer_class attribute with APIView(django rest framework)?
- Django admin how to display widget on readonly field
1👍
As I posted https://stackoverflow.com/a/40145444/6333418 you have to add it to the DIR list that is inside settings.py under TEMPLATES.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['[project name]/templates'], # Replace with your project name
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
- Is it possible to run automatically celery at startup?
- Iphone push notifications passphrase issue (pyAPns)
- Django: "order" a queryset based on a boolean field
- Make Django test case database visible to Celery
- How to change my django server time