簡體   English   中英

缺少Django Grappelli樣式[數字海洋設置]

[英]Django Grappelli style is missing [Digital Ocean Setup]

我在安裝了Django admin的情況下部署了數字海洋飛梭。 當我安裝Django Grappelli並嘗試加載admin時,缺少Django-grappelli的css和js文件,這導致顯示純HTML的頁面出現。 當我檢查元素時,所有必需的grappelli文件都丟失了,代碼為404。

有任何想法嗎??

以下是我的Settings.py僅供參考:

"""
Django settings for django_project project.

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

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

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


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

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

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

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['xxxxxxxxxx']


# Application definition

INSTALLED_APPS = (
    'grappelli',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

MIDDLEWARE_CLASSES = (
    '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_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
    'django.contrib.auth.context_processors.auth',

)

ROOT_URLCONF = 'django_project.urls'

WSGI_APPLICATION = 'django_project.wsgi.application'


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

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

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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

這是我的NGINX配置:

    upstream app_server {
    server 127.0.0.1:9000 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/django_project/django_project/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/django_project/django_project/static;
    }

    # Proxy the static assests for the Django Admin panel
    location /static/admin {
       alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;
    }
}

NGINX錯誤日志:

    2015/05/04 08:52:03 [error] 1056#0: *1060 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1062 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/screen.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/screen.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1063 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/mueller/grid/output.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1064 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1065 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1066 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1060 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:03 [error] 1056#0: *1060 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/"
2015/05/04 08:52:09 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/screen.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/screen.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1069 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/mueller/grid/output.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1071 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1070 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1072 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:09 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/logout/"
2015/05/04 08:52:12 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1069 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/screen.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/screen.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1071 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/mueller/grid/output.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1070 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1072 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1073 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:12 [error] 1056#0: *1067 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1076 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1078 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/screen.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/screen.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1076 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/mueller/grid/output.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1080 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1079 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1081 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1076 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1076 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:52:47 [error] 1056#0: *1076 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:09 [error] 1056#0: *1083 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:09 [error] 1056#0: *1083 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/screen.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/screen.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:09 [error] 1056#0: *1085 open() "/home/django/django_project/django_project/static/grappelli/stylesheets/mueller/grid/output.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/stylesheets/mueller/grid/output.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:09 [error] 1056#0: *1086 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:10 [error] 1056#0: *1088 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:10 [error] 1056#0: *1089 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:10 [error] 1056#0: *1083 open() "/home/django/django_project/django_project/static/grappelli/jquery/jquery-1.9.1.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/jquery-1.9.1.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:10 [error] 1056#0: *1083 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:10 [error] 1056#0: *1083 open() "/home/django/django_project/django_project/static/grappelli/js/grappelli.min.js" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/js/grappelli.min.js HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"
2015/05/04 08:57:14 [error] 1056#0: *1083 open() "/home/django/django_project/django_project/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" failed (2: No such file or directory), client: 89.241.185.12, server: _, request: "GET /static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css HTTP/1.1", host: "178.62.67.237", referrer: "http://178.62.67.237/admin/login/?next=/admin/"

去掉:

# Proxy the static assests for the Django Admin panel
location /static/admin {
   alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
}

從您的nginx conf。 它覆蓋了Django查找應用程序靜態文件的方式,並破壞了Grappelli。

請記住,之后要重新加載nginx。

運行python manage.py collectstatic
這將收集要由Web服務器切斷的靜態文件。

部署靜態文件的官方文檔。

更新

# Proxy the static assests for the Django Admin panel
    location /static/admin {
       alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
    }

這似乎是權限問題。 按照已設置的/ static的方式刪除此塊。 admin css將由collectstatic收集在/ static / admin目錄中。 重新加載nginx。

還要檢查Nginx日志。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM