1Up
1Up

Reputation: 1044

No matter what I specify in settings.py, other template directories not recognized

In my settings.py file I've tried a number of different things, but no matter what I put, it never checks beyond /home/orangeman555/templates/.

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
/home/orangeman555/templates/home.html (File does not exist)

Here is what I have for the TEMPLATES setting:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['templates'],
        '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',

                # `allauth` specific context processors
                'allauth.account.context_processors.account',
                'allauth.socialaccount.context_processors.socialaccount',                
            ],
        },
    },
]

I've tried a variety of things based on stackexchange errors, but no TEMPLATE_DIRS setting seems to get it to "wake up"

This is in a life environment - you can see the errors here

What could I possibly be missing?

.
├── db.sqlite3
├── fabfile.py
├── fabfile.py~
├── fabfile.pyc
├── manage.py
├── req.tx
├── static
│   ├── fonts
│   │   └── bootstrap
│   │       ├── glyphicons-halflings-regular.eot
│   │       ├── glyphicons-halflings-regular.svg
│   │       ├── glyphicons-halflings-regular.ttf
│   │       ├── glyphicons-halflings-regular.woff
│   │       └── glyphicons-halflings-regular.woff2
│   ├── images
│   ├── javascripts
│   │   ├── bootstrap
│   │   │   ├── affix.js
│   │   │   ├── alert.js
│   │   │   ├── button.js
│   │   │   ├── carousel.js
│   │   │   ├── collapse.js
│   │   │   ├── dropdown.js
│   │   │   ├── modal.js
│   │   │   ├── popover.js
│   │   │   ├── scrollspy.js
│   │   │   ├── tab.js
│   │   │   ├── tooltip.js
│   │   │   └── transition.js
│   │   ├── bootstrap.js
│   │   ├── bootstrap.min.js
│   │   └── bootstrap-sprockets.js
│   └── stylesheets
│       ├── framework.css
│       └── styles.css
├── templates # ********TRYING TO LOAD THIS HERE *********
│   ├── base.html
│   ├── flatpages
│   │   └── default.html
│   ├── footer.html
│   ├── home.html
│   ├── menu.html
│   ├── payment-cancel.html
│   ├── payment.html
│   ├── payment-return.html
│   └── profile.html
└── vendsite
    ├── db.sqlite3
    ├── __init__.py
    ├── __init__.py~
    ├── __init__.pyc
    ├── settings.py
    ├── settings.pyc
    ├── signals.py
    ├── signals.pyc
    ├── urls.py
    ├── urls.pyc
    ├── views.py
    ├── views.pyc
    ├── wsgi.py
    └── wsgi.pyc

Upvotes: 0

Views: 63

Answers (1)

Dmitry Yudin
Dmitry Yudin

Reputation: 978

I have this setup in my django 1.8:

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ROOT_PATH = os.path.abspath(os.path.dirname(__file__))

PROJECT_HOST = 'servername.com'
PROJECT_DIR = os.path.dirname(os.path.dirname(__file__))

import os.path
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(ROOT_PATH, 'static/')
MEDIA_ROOT = os.path.join(ROOT_PATH, 'media/')
MEDIA_URL = '/media/'


from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS += (
    "django.core.context_processors.request",

)

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates'),
)
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader'
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#   'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

end when i have project/templates/base.html -its works fine and even when i have project/application/templates/app_html.html it works too. If something still go wrong set permissions like :

  1. chmod 777 dir/*
  2. chmod 777 dir/file.html

Upvotes: 1

Related Questions