簡體   English   中英

無論我在settings.py中指定什么,其他模板目錄都無法識別

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

在我的settings.py文件中,我嘗試了許多不同的操作,但是不管我放什么,它都不會超過/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)

這是我對TEMPLATES設置的要求:

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',                
            ],
        },
    },
]

我已經嘗試過各種基於stackexchange錯誤的方法,但是沒有TEMPLATE_DIRS設置似乎可以使它“喚醒”

這是在生活環境中-您可以在此處看到錯誤

我可能會丟失什么?

.
├── 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

我的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',
)

當我有project / templates / base.html-結束時,它可以正常工作,即使當我有project / application / templates / app_html.html時,它也可以工作。 如果仍有問題,請設置以下權限:

  1. chmod 777目錄/ *
  2. chmod 777目錄/file.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM