Python Django管理页面缺少部署时的全选复选框
我已经在DigitalOcean.com上部署了我的Django项目。我已经设置了静态文件夹并运行了正常运行的Python Django管理页面缺少部署时的全选复选框,python,django,django-deployment,Python,Django,Django Deployment,我已经在DigitalOcean.com上部署了我的Django项目。我已经设置了静态文件夹并运行了正常运行的python manage.py collectstatic。唯一的问题是我在管理页面中看不到全选复选框 这是在我当地的Django项目中: 这是在部署的项目中: import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os
python manage.py collectstatic
。唯一的问题是我在管理页面中看不到全选复选框
这是在我当地的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/'
我想不出问题出在哪里。你知道吗
我正在附加已部署项目的settings.py
:
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/'
我只是面临同样的问题(至少是同样的影响)。结果证明(我认为)这是一个缓存问题,无论是在nginx上还是在客户端浏览器上: 我的生产服务器使用Debian jessie、nginx、gunicorn、Django 1.10.2+SSL 要测试是否存在缓存问题,请运行(如果prod服务器允许)
(或您可以访问的任何其他端口)在生产服务器上运行一段时间。并在那里测试复选框是否存在。如果是,则只需重新启动服务器服务并强制浏览器缓存刷新几次(在我知道的大多数浏览器上按shift键并单击刷新箭头)。我刚刚遇到了相同的问题(至少效果相同)。结果证明(我认为)这是一个缓存问题,无论是在nginx上还是在客户端浏览器上: 我的生产服务器使用Debian jessie、nginx、gunicorn、Django 1.10.2+SSL 要测试是否存在缓存问题,请运行(如果prod服务器允许)
(或您可以访问的任何其他端口)在生产服务器上运行一段时间。并在那里测试复选框是否存在。如果是,则只需重新启动服务器服务并强制浏览器缓存刷新几次(在我知道的大多数浏览器上按shift键并单击刷新箭头)。我也遇到了同样的问题,并修复了该问题备份静态文件夹中的所有数据,清空它,然后再次执行:
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.
清空文件夹我强制命令重新复制bak中的所有内容,之后所有内容都正常工作。我遇到了同样的问题,并修复了它备份静态文件夹中的所有数据,清空它,然后再次执行:
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.
清空文件夹时,我强制命令将所有内容重新复制到bak,之后所有内容都正常工作。只是为了确保您在本地和生产中使用的是相同的django版本,对吗?@JahongirRahmonov可能是的,我已经检查过了。1点10分。0@JahongirRahmonov我已经检查过了,我在那里看到了1.10.0,但是settings.py说:由使用django 1.9.7的“django admin startproject”生成。这些设置最初来自我的本地项目。尝试使版本相同,然后查看结果。只是为了确保您在本地和生产中使用的是相同的django版本,对吗?@JahongirRahmonov可能是的,我查过了。1点10分。0@JahongirRahmonov我已经检查过了,我在那里看到了1.10.0,但是settings.py说:由使用django 1.9.7的“django admin startproject”生成。这些设置最初来自我的本地项目。尝试使版本相同,然后查看结果。