简体   繁体   English

缺少Django-admin页面,请选中部署时的所有复选框

[英]Django-admin page is missing select all checkbox on deploy

I've deployed my Django project on DigitalOcean.com. 我已经在DigitalOcean.com上部署了我的Django项目。 I've set static folder and run python manage.py collectstatic which worked correctly. 我已经设置了静态文件夹并运行正常运行的python manage.py collectstatic The only problem is that I can't see select all checkbox in admin page. 唯一的问题是我看不到“管理”页面中的“全部选中”复选框。

This is in my local Django project: 这是在我的本地Django项目中:

在此处输入图片说明

And this is in deployed project: 这是在已部署的项目中:

在此处输入图片说明

I can't figure out where the problem is. 我不知道问题出在哪里。 Do you know? 你知道吗?

I'm attaching settings.py of deployed project: 我要附加已部署项目的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/'

I had the same problem and fixed it backing up all data in my static folder, emptying it and executing again: 我遇到了同样的问题,并修复了备份静态文件夹中的所有数据,清空它并再次执行的问题:

python manage.py collectstatic

I figured out it was because of static files from a previous app I had installed (django-grappelli). 我发现这是由于安装了以前的应用程序(django-grappelli)中的静态文件所致。 Django was trying to move file needed to the destination /static/ folder, but as there were already the same files created by django-grapelli it just ignored them and doesn't moved them. Django试图将所需的文件移动到目标/ static /文件夹,但是由于django-grapelli已经创建了相同的文件,因此它只是忽略了它们而没有将它们移动。 Example: 例:

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.

Emptying the folder I forced the command to recopy everything bak there and everything worked fine afterwards. 清空文件夹后,我强制命令重新复制那里的所有bak,之后一切正常。

I just faced the same issue (at least same effects). 我只是面临相同的问题(至少具有相同的效果)。 It turned out to be (I think) a cache issue, either on nginx or on the client browser: 事实证明,这是(我认为)nginx或客户端浏览器上的缓存问题:

My production server works with Debian jessie, nginx, gunicorn, Django 1.10.2 + SSL. 我的生产服务器可与Debian jessie,nginx,gunicorn,Django 1.10.2 + SSL一起使用。

To test if you have a cache problem, run (if your prod server allows this) 要测试是否有缓存问题,请运行(如果您的产品服务器允许这样做)

./manage.py runserver 0.0.0.0:8000

(or any other port you can access) on your production server for a short while. (或您可以访问的任何其他端口)在生产服务器上等待一会儿。 And test there if the checkbox is present. 并在那里检查该复选框是否存在。 If yes, than just restart your server services and force the browser cache refresh a few times (hit shift+click on the refresh arrow on most of the browser I know). 如果是,则不只是重启服务器服务并强制浏览器缓存刷新几次(按Shift键并单击我所知道的大多数浏览器上的刷新箭头)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM