服务器重启后,Django CMS页面不可见

时间:2016-10-02 16:13:45

标签: django-cms

我一直在使用django-cms为我的GF建立一个简单的网站。我正在编辑基本模板,由于某种原因我的更改没有通过,所以我重新启动nginx服务器脚本只是为了发现我的恐怖,我再也看不到任何页面内容,只有他们的名字在管理界面中的树。如果我尝试转到某个页面,则声称该页面不存在。

我想也许设置有问题所以我运行了修复树和迁移(这可能是我的错误),现在甚至在管理界面中也不再可见页面名称了。页面及其内容位于数据库中,但不再可访问它们。

有没有人遇到过类似的问题?可能是什么原因/解决方案?任何想法在哪里看

我的猜测是设置有问题,或者我的某个软件包的版本错误,然后在重新启动之前我没有遇到麻烦。

我希望让所有这些页面都回归,特别是它们仍然存在于数据库中。将永远感激任何帮助。

修改

我刚试过创建一个新页面。我能够没有任何错误地执行此操作,页面在数据库中可见但在“页面”页面上不可见,并且页面slug出现404错误。

编辑2

这是requirements.txt

aldryn-apphooks-config==0.2.7
aldryn-boilerplates==0.7.4
aldryn-bootstrap3==1.0.10
aldryn-categories==1.0.3
aldryn-common==1.0.4
aldryn-newsblog==1.2.4
aldryn-people==1.2.1
aldryn-reversion==1.0.9
aldryn-style==1.1.1
aldryn-translation-tools==0.2.1
aldryn-video==1.0.0
Babel==2.3.4
backport-collections==0.1
beautifulsoup4==4.4.1
dj-database-url==0.4.1
Django==1.8.15
django-appconf==1.0.2
django-appdata==0.1.5
django-classy-tags==0.8.0
django-cms==3.2.5
django-durationfield==0.5.2
django-filer==1.2.4
django-formtools==1.0
django-mptt==0.8.6
django-parler==1.6.5
django-phonenumber-field==1.1.0
django-polymorphic==0.8.1
django-reversion==1.8.7
django-sekizai==0.10.0
Django-Select2==4.3.2
django-sortedm2m==1.3.2
django-taggit==0.21.2
django-treebeard==4.0.1
djangocms-admin-style==1.2.3
djangocms-attributes-field==0.1.1
djangocms-column==1.6.0
djangocms-file==1.0
djangocms-googlemap==0.5.1
djangocms-inherit==0.2.1
djangocms-installer==0.8.7
djangocms-link==1.8.2
djangocms-picture==0.2.0
djangocms-style==1.7.0
djangocms-teaser==0.2.0
djangocms-text-ckeditor==3.1.0
djangocms-video==1.0.0
easy-thumbnails==2.3
gevent==1.1rc3
greenlet==0.4.9
gunicorn==18.0
html5lib==0.9999999
jsonfield==1.0.3
lxml==3.6.4
micawber==0.3.3
phonenumbers==7.5.2
phonenumberslite==7.5.2
Pillow==3.3.1
psycopg2==2.6.1
python-dateutil==2.5.3
python-slugify==1.2.0
pytz==2016.6.1
six==1.10.0
tzlocal==1.2.2
Unidecode==0.4.19
virtualenv==15.0.1
webencodings==0.5
YURL==0.13

这是设置文件:

import os

gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
"""
Django settings for anninsivut project.

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

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

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

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

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

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

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

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

ALLOWED_HOSTS = ['.site.com', ]

# Application definition





ROOT_URLCONF = 'anninsivut.urls'

WSGI_APPLICATION = 'anninsivut.wsgi.application'

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




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

LANGUAGE_CODE = 'en'

TIME_ZONE = 'Europe/Amsterdam'

USE_I18N = False

USE_L10N = False

USE_TZ = True

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

STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'anninsivut', 'media')
STATIC_ROOT = os.path.join(DATA_DIR, 'anninsivut', 'static')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'anninsivut', 'common_static'),

)
SITE_ID = 1

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'anninsivut', 'templates'), ],
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.i18n',
                'django.core.context_processors.debug',
                'django.core.context_processors.request',
                'django.core.context_processors.media',
                'django.core.context_processors.csrf',
                'django.core.context_processors.tz',
                'sekizai.context_processors.sekizai',
                'django.core.context_processors.static',
                'cms.context_processors.cms_settings',
                'aldryn_boilerplates.context_processors.boilerplate',
            ],
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader',
                'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
            ],
        },
    },
]

MIDDLEWARE_CLASSES = (

    # 'cms.middleware.utils.ApphookReloadMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'cms.middleware.user.CurrentUserMiddleware',
    'cms.middleware.page.CurrentPageMiddleware',
    'cms.middleware.toolbar.ToolbarMiddleware',
    'cms.middleware.language.LanguageCookieMiddleware'
)

INSTALLED_APPS = (
    'djangocms_admin_style',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'cms',
    'menus',
    'sekizai',
    'treebeard',
    'djangocms_text_ckeditor',
    'djangocms_style',
    'djangocms_column',
    'djangocms_file',
    'djangocms_googlemap',
    'djangocms_inherit',
    'djangocms_link',
    'djangocms_picture',
    'djangocms_teaser',
    'aldryn_video',
    'reversion',
    'aldryn_apphooks_config',
    'aldryn_boilerplates',
    'aldryn_categories',
    'aldryn_common',
    'aldryn_translation_tools',
    'aldryn_newsblog',
    'aldryn_people',
    'aldryn_reversion',
    'aldryn_bootstrap3',
    'parler',
    'sortedm2m',
    'taggit',
    'easy_thumbnails',
    'filer',
    'anninsivut'
)

LANGUAGES = (
    ## Customize this
    ('en', gettext('en')),
)

ALDRYN_BOILERPLATE_NAME = 'bootstrap3'

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

CMS_LANGUAGES = {
    ## Customize this
    1: [
        {
            'name': gettext('en'),
            'redirect_on_fallback': True,
            'code': 'en',
            'public': True,
            'hide_untranslated': False,
        },
    ],
    'default': {
        'redirect_on_fallback': True,
        'hide_untranslated': False,
        'public': True,
    },
}

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    # 'easy_thumbnails.processors.scale_and_crop',  # disable this one
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters',
)

CMS_TEMPLATES = (
    ## Customize this
    ('page.html', 'Page'),
    ('feature.html', 'Page with Feature')
)

CMS_PERMISSION = True

CMS_PLACEHOLDER_CONF = {}

DATABASES = {
    'default': {
        'CONN_MAX_AGE': 0,
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'HOST': 'localhost',
        'NAME': 'anninsivut_DB',
        'PASSWORD': 'password',
        'PORT': '',
        'USER': 'user'
    }
}
DEFAULT_FROM_EMAIL = 'name@domain.com'
SERVER_EMAIL = 'name@domain.com'
ADMINS = (
    ('Your name', 'your email address'),
)
MIGRATION_MODULES = {

}

@Paulo感谢您的要求。现在我查看了需求和设置文件,我发现我在本地Pycharm目录上的需求文件没有与服务器上的那个同步。在某些时候,我一定不小心在服务器的venv中升级到了Django 1.9。现在我猜测当我重新启动时,当Django-CMS接收到更改并丢失了页面内容时。然后,当我看到丢失并降级回1.8时,那时我在页面树上丢失了页面名称。我将首先介绍两者之间的变化,看看这些软件包是否与它们应该是最新的。

1 个答案:

答案 0 :(得分:1)

好的,我设法解决了。在Pycharm中调试调试器中的代码后,我意识到我不小心注释掉了

LANGUAGE_CODE = 'en'

设置中的

行使Django恢复为LANGUAGE_CODE ='en-us',这就是为什么它无法找到页面。

我在PyCharm和部署服务器之间也遇到了同步问题,这就是我在这里发布的settings.py中注释LANGUAGE_CODE = 'en' 而不是的原因。

简而言之:

语言代码必须在

中匹配的TIL

LANGUAGE_CODE = 'en'

CMS_LANGUAGES = { 1: [ { 'name': gettext('en'), 'redirect_on_fallback': True, 'code': 'en', 'public': True, 'hide_untranslated': False, }, ], 'default': { 'redirect_on_fallback': True, 'hide_untranslated': False, 'public': True, }, }

相关问题