Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么django找不到站点包中已安装的第三方应用程序的模板?_Python_Django_Templates_Django Settings_Django Middleware - Fatal编程技术网

Python 为什么django找不到站点包中已安装的第三方应用程序的模板?

Python 为什么django找不到站点包中已安装的第三方应用程序的模板?,python,django,templates,django-settings,django-middleware,Python,Django,Templates,Django Settings,Django Middleware,我最近剥离了一个旧项目,尝试安装它的应用程序(这很有效),还安装了django helpdesk/bootstrap_表单。但是django既找不到帮助台模板,也找不到引导模板。My settings.py看起来像: import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # SECURITY WARNING: keep the secret key used in productio

我最近剥离了一个旧项目,尝试安装它的应用程序(这很有效),还安装了django helpdesk/bootstrap_表单。但是django既找不到帮助台模板,也找不到引导模板。My settings.py看起来像:

import os

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


# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'key'

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts',
    'index',
    'taggit',
    'helpdesk',
    'bootstrapform',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

HELPDESK_PATH       = "/home/cchilders/.local/virtualenv/new_bookmarks/lib/python2.7/site-packages/helpdesk/templates",
BOOSTRAPFORM_PATH   = "/home/cchilders/.local/virtualenv/new_bookmarks/lib/python2.7/site-packages/bootstrapform/templates"

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates"), 
                "/home/cchilders/.local/virtualenv/new_bookmarks/lib/python2.7/site-packages/helpdesk/templates",
                "/home/cchilders/.local/virtualenv/new_bookmarks/lib/python2.7/site-packages/bootstrapform/templates",],

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

STATIC_ROOT = '/home/cchilders/django_practice/new_bookmarks/static'
STATIC_URL = '/static/'
我现在没有问题,但我很困惑为什么我必须手动执行HELPDESK_路径和BOOSTRAPFORM_路径。上一次,我用相同的模板配置安装应用程序,实现了这一目标。我已安装了以下设备:

Django==1.8.3
argparse==1.2.1
betterpath==0.2.2
django-bootstrap-form==3.2
django-extensions==1.5.5
django-helpdesk==0.1.16
django-markdown-deux==1.0.5
django-mptt==0.7.4
django-taggit==0.16.2
email-reply-parser==0.3.0
ipython==3.2.1
l==0.3.1
lxml==3.4.4
markdown2==2.3.0
pytz==2015.4
requests==2.7.0
simplejson==3.8.0
six==1.9.0
vcversioner==2.14.0.0
wsgiref==0.1.2
zope.interface==4.1.2
我正在运行一个VE(就像它找到模板时一样),包在预期的位置:

~/.local/virtualenv/new_bookmarks/lib/python2.7/site packages/bootstrapform/templates

当关闭新URL返回到
'DIRS':[os.path.join(BASE_DIR,“templates”),]时,
我得到

TemplateDoesNotExist at /helpdesk/
helpdesk/public_homepage.html


Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/cchilders/django_practice/new_bookmarks/templates/helpdesk/public_homepage.html (File does not exist)

我不明白为什么它不检查通常的地方。我的VE可以工作,如果我停用它,我将无法运行服务器,因为缺少像“taggit”这样的包。什么通常会导致django忽略站点包,而不查找BASE_DIR/templates之外的模板?谢谢你,是不是因为你把APP_DIRS设置为False?是的,这就是原因。我认为他们之间的冲突是有原因的,并且已经这样做了一段时间了。谢谢你,罗斯曼先生,是不是因为你把APP_DIRS设置为False?是的,这就是原因。我认为他们之间的冲突是有原因的,并且已经这样做了一段时间了。谢谢你,罗斯曼先生