我已在DigitalOcean.com上部署了我的Django项目。我已设置静态文件夹并运行正常运行的settings.py
。唯一的问题是我无法在管理页面中看到全选复选框。
这是我当地的Django项目:
这是在已部署的项目中:
我无法找出问题所在。你知道吗?
我附加已部署项目的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__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'some key'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main_app',
'django.contrib.admin',
'django_tables2',
'import_export',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'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',
]
ROOT_URLCONF = 'drevo.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
WSGI_APPLICATION = 'drevo.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME':'/home/django/drevo/db.sqlite3',
#'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/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',
},
]
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'email@gmail.com'
EMAIL_HOST_PASSWORD = 'pwd'
ADMIN_EMAIL = 'email@gmail.com'
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
VARS_MODULE_PATH = 'main_app.global_variables.py'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = '/home/django/drevo/static/'
STATIC_URL = '/static/'
:
{{1}}
答案 0 :(得分:1)
我遇到了同样的问题并修复了备份静态文件夹中的所有数据,清空并再次执行:
python manage.py collectstatic
我发现这是因为我安装的先前应用程序的静态文件(django-grappelli)。 Django试图将目标/ static /文件夹所需的文件移动,但由于django-grapelli已经创建了相同的文件,它只是忽略了它们并且没有移动它们。例如:
Found another file with the destination path 'admin/css/dashboard.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
清空文件夹我强制命令重新复制那里的所有内容,之后一切正常。
答案 1 :(得分:0)
我刚遇到同样的问题(至少有同样的效果)。事实证明(我认为)是在nginx或客户端浏览器上的缓存问题:
我的生产服务器适用于Debian jessie,nginx,gunicorn,Django 1.10.2 + SSL。
要测试您是否有缓存问题,请运行(如果您的prod服务器允许)
./manage.py runserver 0.0.0.0:8000
您的生产服务器上的(或您可以访问的任何其他端口)。如果复选框存在,则在那里进行测试。如果是,那么只需重新启动服务器服务并强制刷新浏览器缓存几次(点击shift +点击我知道的大多数浏览器上的刷新箭头)。