- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我们正在使用 django-compressor
和 django.contrib.staticfiles
应用程序,但在运行 django 开发服务器和处理我们的 SCSS 时遇到问题:编译了错误的 SCSS 文件。找到 STATIC_ROOT/app
中的版本,而不是 app/static 中的版本。这使得在 app/static
中对 SCSS 的编辑不会反射(reflect)在编译的 CSS 中。
删除 STATIC_ROOT/app
中的所有内容可解决此问题,但如果出于某种原因执行 collectstatic
会导致很多困惑。
有没有办法确保编译的是应用程序/静态文件而不是任何现有的 STATIC_ROOT/应用程序文件?
我们将 django-compressor 1.4 与 django 1.6 一起使用,并且在 django 设置文件中使用了以下设置:
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
'compressor.finders.CompressorFinder',
)
COMPRESS_PRECOMPILERS = (
("text/x-scss", 'sass --scss'),
)
STATICFILES_DIRS = [] #default
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
最佳答案
COMPRESS_PRECOMPILERS
中的sass --scss
命令没有明确说明目标目录。因此使用默认值,即 seems to be stdin
and stdout
.
现在,压缩器文档并不清楚使用 stdout
意味着什么;但是,从示例来看,文件似乎最终会在 COMPRESS_ROOT 中结束。 (默认为 STATIC_ROOT/CACHE
,在您的情况下为 root/base/static/CACHE/
)
我个人喜欢明确说明输入/输出目录(以在不同环境中保持不变)。这是一个示例(使用 pyScss 编译器,但思路是一样的):
scss_cmd = '{python} -mscss -A "{image_output_path}" -a "{static_url}" ' \
'-S "{static_root}" -o "{{outfile}}" "{{infile}}"'.format(
python=sys.executable,
image_output_path=COMPRESS_ROOT,
static_url=STATIC_URL,
static_root=os.path.join(PROJECT_ROOT),
)
COMPRESS_PRECOMPILERS = (
('text/x-scss', scss_cmd),
)
(抱歉,如果挖掘长期被遗忘的问题)
关于python - django-compressor 在 STATIC_ROOT/app 而不是 app/static 中编译 SCSS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26770121/
我是 Django 的新手,我正在尝试找到一种方法来在我的元素中加载我的 css 文件。这是我的 settings.py 文件 STATICFILES_STORAGE = 'whitenoise.dj
我从项目中的一些模板中渲染了一些 pdf。好吧,这似乎可行,但是...... ...我想测试一下! 问题是我在渲染期间读取的一些文件位于 STATIC_ROOT 中 - 因此我需要在运行测试时收集静态
当我尝试在 webfacional 的服务器上运行 webapp 时,我陷入了关于 STATIC_URL 和 STATIC_ROOT 的问题 2 小时。 当我加载网页时,所有请求都运行良好,除非任何带
我已经通过官方文档和一些文章阅读了有关它们的内容,但我仍然感到困惑。就我现在所知,MEDIA_ROOT用于用户上传的图像和文件,而STATIC_ROOT用于js,css等。至于MEDIA_URL,是否
我正在 Heroku 上部署一个 Django 应用程序。 在我的设置模块中,我已配置为托管静态文件,例如 STATIC_ROOT = os.path.join(BASE_DIR, 'static_m
我对 Django 中的静态文件和媒体文件感到困惑。我在其他地方看到人们可以互换使用它。 我应该什么时候使用 media_root我什么时候应该使用 static_root ? 如果我有网站图片,我应
我使用的是 Django 1.7。将我的网站部署到生产服务器并运行 collectstatic 时,我收到以下错误消息: django.core.exceptions.ImproperlyConfig
我正在使用此 STATIC_ROOT 和 MEDIA_ROOT 配置: STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BA
我在 settings.py中有一个 Django 1.3 项目,此选项。 SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) STATIC
在我的settings.py 文件中,STATIC_ROOT 和MEDIA_ROOT 目前都指向硬编码位置。例如STATIC_ROOT路径是: /home/ian/projectname/mysite
我很难将项目部署到heroku,因为它说找不到静态文件。我的静态文件位于名为“static”的文件夹中名为“social”的应用程序中,它们不在 management.py 所在的基本目录中。 --p
我正在使用 Python 3.5 和 Django 1.10 来运行开发服务器: ./manage.py runserver 0.0.0.0:8000 在我的 settings.py我有: DEBUG
我的 STATIC_ROOT 文件夹指定为 /var/www/app_name/static,非 sudo 用户通常不应访问该文件夹。 它是由具有 sudo 权限的用户创建的。现在我正在尝试对我自己的
这三个静态url有什么区别? 我不确定我是否正确,我正在使用 MEDIA_ROOT 来存储我上传的照片(通过 models.ImageField()) 但是,我在 admin.py 中为我的管理员创建
我已经浏览了所有其他答案,但似乎无法找到任何对我有用的东西。我正在遵循教程并尝试将我的 master 分支推送到 heroku 并收到错误您正在使用 staticfiles 应用程序,而没有将 STA
我对 static root 感到困惑,想澄清一些事情。 要在 Django 中提供静态文件,settings.py 和 urls.py 中应包含以下内容: import os PROJECT_DIR
对于 Django 的 'staticfiles' 应用程序中 STATIC_URL 和 STATIC_ROOT 之间的区别,我有些困惑。 我相信我了解 STATIC_ROOT 是什么:它本质上是服务
我想在文件夹中添加特定的 Assets ,并且应该能够使用像/assets/css/main.css 这样的 url 进行访问 我可以使用/static/css/main.css 但不能使用/asse
我正在使用 Django 2.2。来自 Django 管理静态文件 documentation : If you use django.contrib.staticfiles as explained
我是 Django 和 Web 应用程序开发的新手。我正在尝试将 css 添加到我的演示站点(在 Windows7 上使用 django v1.4)并收到以下错误。我都试过了,浪费了将近 3-4 个小
我是一名优秀的程序员,十分优秀!