我的项目结构是
myproject - settings.py - static-media - urls.py - media - manage.py
其中static-media是包含此项目的静态文件的文件夹.在我的settings.py中,我有:
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__)) STATIC_ROOT = os.path.join(PROJECT_PATH,"static")+'/' STATIC_URL = "/static/" STATICFILES_Dirs = ( os.path.join(PROJECT_PATH,'static-media'),)
我正在使用admin_tools来更改管理员的布局.但是我想从admin_tools覆盖特定的css文件(theming.css).所以在我的静态媒体文件夹中我放了admin_tools / css / theming.css.
当我第一次运行python manage.py collectstatic时,它会按预期工作,忽略admin_tools中的默认的theming.css并使用我在static-media中定义的那个.不幸的是,如果我再次运行该命令,它会覆盖我的css并添加默认值.
这是python manage.py findstatic admin_tools / css / theming.css的输出:
Found 'admin_tools/css/theming.css' here: /home/paulo/Desktop/Projects/zennetwork/prd/zennetwork/static-media/admin_tools/css/theming.css /home/paulo/Desktop/Projects/zennetwork/prd/lib/python2.7/site-packages/admin_tools/theming/static/admin_tools/css/theming.css
任何帮助表示赞赏.谢谢.
解决方法
Duplicate file names are by default resolved in a similar way to how template resolution works: the file that is first found in one of the specified locations will be used. If you’re confused,the findstatic command can help show you which files are found.
根据findstatic的输出,第一个应该是您的自定义样式,因此应该是收集的样式.为什么它不这样做是一个谜.
你总是可以明确地忽略其他文件.这有点痛苦,但它会保证你的风格不会被覆盖:
python manage.py collectstatic --ignore site-packages/admin_tools/css/theming.css
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。