简体   繁体   English

django-staticfiles打破了管理界面

[英]django-staticfiles breaking the admin interface

I'm using the django-staticfiles app to serve css files, but this also prevents required admin css files (media/base.css, media/dashboard.css) from being loaded. 我正在使用django-staticfiles应用程序来提供css文件,但这也可以防止加载所需的admin css文件(media / base.css,media / dashboard.css)。 It seems like I need to exclude the admin app, but adding it to the STATICFILES_EXCLUDED_APPS hasn't helped. 好像我需要排除管理员应用程序,但将其添加到STATICFILES_EXCLUDED_APPS并没有帮助。

Here are the relevant bits from my settings.py file: 以下是我的settings.py文件中的相关位:

ADMIN_MEDIA_PREFIX = '/media/'

...

STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_EXCLUDED_APPS = (
    'django.contrib.admin',
)

INSTALLED_APPS = (
    ...

    'django.contrib.admin',
    'staticfiles',

)

(I'll assume this is for development as you shouldn't serve static content with django-staticfiles.) (我假设这是用于开发的,因为你不应该使用django-staticfiles提供静态内容。)

You have to define the ADMIN_MEDIA_ROOT variable in your settings.py file and point it to the location of the admin css files. 您必须在settings.py文件中定义ADMIN_MEDIA_ROOT变量,并将其指向admin css文件的位置。 I've moved these files out of site-packages to be in a similar location as my other static files for ease of deployment. 我已经将这些文件从站点包中移出到与我的其他静态文件类似的位置,以便于部署。

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

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