Django grappelli seems unable to see all of his media files

I have django 1.4 and grappelli 2.4.3 running on an Ubuntu server that I look through the Windows network system when they are being produced. Everything works fine on the development server when I view it on an Ubuntu machine using RDP.

Relevant settings.py sections:

STATIC_ROOT = os.path.join(os.path.dirname(__file__), '../03_static_files/collected/')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    os.path.join(os.path.dirname(__file__), '../03_static_files/'),
    os.path.join(os.path.dirname(__file__), '../03_static_files/admin/'),
    os.path.join(os.path.dirname(__file__), '../03_static_files/filebrowser/'),
    os.path.join(os.path.dirname(__file__), '../03_static_files/grappelli/'),
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # apps I added but didn't create
    'south',
    'grappelli',
    'filebrowser',
    'tinymce',
    'haystack',
    'gunicorn',
    'debug_toolbar',
    'taggit',

    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',

    # apps I created
    'community',
    'fts',
    'guidance',
    'news',
)

I started collectstatic, but the admin site is clearly partially displayed. This definitely picks up some CSS because some elements are stylized. But it does not raise others because it looks like a mess. Neither my Nginx error logs nor Gunicorn show any 404s, and I can download all the css and js files if I point to my browser right away.

Currently, the admin site looks both in IE8 and IE9:

half-rendered grappelli

. Django , () . django , grappelli . Nginx

location /admin/media/ {
    root /path/to/django/contrib;
}

location /admin/media/ {
    root /path/to/grappelli;
}

. - , ?

+5
4

: TEMPLATE_DIRS ? , . , diegueus9, grappelli css , - , Django.

+2

, .

...

STATIC_URL = '/static/' 
STATIC_ROOT is something like os.path.join(PROJECT_PATH, "static"),
ADMIN_MEDIA_PREFIX = '/static/grappelli/' (or whatever your static directory is)

DEBUG = False or True ?
TEMPLATE_DEBUG = DEBUG

false, nginx

...

STATIC_URL = '/static/'
STATIC_ROOT = '/home/foo/devel/static'
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/foo/devel/media'
# the following is deprecated but is it seems grappelly requires it
ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/"
STATIC_FILES = ()
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
+1

, Django 1.4.3 admin, Grappelli . , , , .

Django 1.4.2 , , , , 'django.contrib.admin' INSTALLED_APPS ( - ), collectstatic -c . , Grappelli.

+1
source

My best guest, without looking at your settings.py, is that your "grappelli" application is installed after the django admin, not before . See the warning in setup doc

It is clear that your css and js are correct, but do not render well, because your application creates django.contrib.admin templates.

Please be sure to install grappelli before:

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

All Articles