Django部署到服务器后寻找index.html

时间:2019-10-11 15:13:37

标签: django nginx django-deployment

在升级服务器上的所有相关软件包以匹配开发服务器上的软件包之后,我刚刚将新代码部署到服务器上。我知道models.py文件已经更改,并且迁移文件不匹配,但是我可以删除当前数据库,因为它不需要并且不需要在这种情况下进行存档。服务器在以前的网站上运行良好,所以我希望Gunicorn和Nginx的配置不应该成为此问题的一部分(如果有的话,我会明确提及)。

因此,现在我的网站在使用django的dev服务器的笔记本电脑上运行良好,现在已使用git pull部署到该服务器,效果很好,该服务器上的代码现在与master分支匹配。我正在运行一个具有python 3.6的虚拟环境(virtualenv),但由于未知原因,该处也有python 2.7,但我不知道要在该环境中进行安装(我从未在python2.7中进行过编程,因此永远不要安装它,尽管我知道它是操作系统的一部分,所以应该在那里安装它,只是不在虚拟环境中。

但是现在,当我单击应转到该站点的链接时,它正在寻找index.html,而我在站点中没有任何位置,它应该在寻找home.html。因此,我假设django的默认设置正在寻找它。对此的任何帮助将不胜感激,这里是回溯和初学者的settings.py文件:

Environment:


Request Method: GET
Request URL: http://10.88.58.95/

Django Version: 2.1.5
Python Version: 3.6.7
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'microblog']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Template loader postmortem
Django tried loading these templates, in this order:

Using engine django:
    * django.template.loaders.filesystem.Loader: /webapps/pcc_django/pcc_django/templates.           /microblog/index.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/contrib/admin/templates/microblog/index.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/contrib/auth/templates/microblog/index.html (Source does not exist)



Traceback:

File "/webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

_get_response中的文件“ /webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/core/handlers/base.py”       124. response = wrapd_callback(request,* callback_args,** callback_kwargs)

File "/webapps/pcc_django/pcc_django/microblog/views.py" in index
  12.     DeleteView,

File "/webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/shortcuts.py" in render
  36.     content = loader.render_to_string(template_name, context, request, using=using)

File "/webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/template/loader.py" in render_to_string
  61.         template = get_template(template_name, using=using)

File "/webapps/pcc_django/django_env/lib64/python3.6/site-packages/django/template/loader.py" in get_template
  19.     raise TemplateDoesNotExist(template_name, chain=chain)

Exception Type: TemplateDoesNotExist at /
Exception Value: microblog/index.html

Setting.py

"""
Django settings for django_version project.

Generated by 'django-admin startproject' using Django 2.1.4.

For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
STATIC_DIR = os.path.join(BASE_DIR, "static")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

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

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['**.**.**.**', '127.0.0.1']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.messages',
    'django.contrib.sessions',
    'django.contrib.staticfiles',
    'django_filters',
    'microblog.apps.MicroblogConfig',
    'project_portal.apps.ProjectPortalConfig',
    'url_tree.apps.UrlTreeConfig',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'django_version.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR, ],
        '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',
                'django_version.context_processors.link_category',
                'django_version.context_processors.sidebar_links',
            ],
        },
    },
]

WSGI_APPLICATION = 'django_version.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'pcc_db',
        'USER': 'pcc',
        'PASSWORD': 'Hamilton1',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/

LANGUAGE_CODE = 'en-GB'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

DATE_INPUT_FORMATS = [
    '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
    '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
    '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '25 October, 2006'
]


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
    STATIC_DIR,
]

LOGIN_REDIRECT_URL = '/si/list/All/'

0 个答案:

没有答案