python C django collectstatic overriding
我的项目结构是
myproject
- settings.py
- static-media
- urls.py
- media
- man
我正在使用Django 1.3.1和contrib.collectstatic应用来管理我的静态文件. 我的项目结构是 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 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任何帮助表示赞赏.谢谢. 解决方法 Django docs只说: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如果您还需要忽略其他文件,可以继续添加Cignore< pattern>.不过,这无疑是一个非常可行的长期解决方案. (编辑:大庆站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 想在Jupyter Notebook(Anaconda)中保存并运行Python脚本
- python-3.x – Keras(TensorFlow,CPU):训练循环中的顺序模
- python – matplotlib自定义图例中类别的子标题
- 最优雅的方式来分离基于模式的列表(Python)
- python – 整数除法:对于所有整数a,b,// b == int(a / b)为
- Python:如何在字符串中剪切超过2个相等字符的序列
- python相当于scala分区
- python – 是一个无限的循环不良练习?
- 根据其属性为python对象生成唯一的ID
- python – TensorFlow:Hadamard产品::我如何得到这个?