为什么 collectstatic 不会复制我的静态文件? [英] Why won't collectstatic copy my static files?

查看:27
本文介绍了为什么 collectstatic 不会复制我的静态文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 MyApp/static/MyApp 目录.

当我运行 ./manage.py collectstatic 时,我希望 MyApp 目录被复制到 STATIC_ROOT,但它没有.

When I run ./manage.py collectstatic, I expect the MyApp directory be copied to STATIC_ROOT, but it doesn't.

我也有 DownloadedApp/static/DownloadedApp 并将其复制到 STATIC_ROOT 很好.

I have DownloadedApp/static/DownloadedApp as well and its copied to STATIC_ROOT fine.

我错过了什么?

推荐答案

STATIC_ROOTSTATICFILES_FINDERSSTATICFILES_DIRS 在你的<代码>settings.py?

collectstatic 运行时,默认的 STATICFILES_FINDERSdjango.contrib.staticfiles.finders.FileSystemFinder 将从任何路径收集您的静态文件您在 STATICFILES_DIRS 中拥有的内容.

When collectstatic is run, the default STATICFILES_FINDERS value django.contrib.staticfiles.finders.FileSystemFinder will collect your static files from any paths that you have in STATICFILES_DIRS.

另一个默认的 STATICFILES_FINDERSdjango.contrib.staticfiles.finders.AppDirectoriesFinder 将在任何应用程序的 /static/ 文件夹中查找你的INSTALLED_APPS.

The other default STATICFILES_FINDERS value django.contrib.staticfiles.finders.AppDirectoriesFinder will look in the /static/ folder of any apps in your INSTALLED_APPS.

找到的所有静态文件都将放置在指定的STATIC_ROOT目录中.

All of the static files that are found will be placed in the specified STATIC_ROOT directory.

查看 collectstatic 文档的链接

此链接解释了设置中的各种静态设置.py

您也可以使用 python manage.py findstatic 来查看 collectstatic 将查找哪些目录.

You can also use python manage.py findstatic to see which directories collectstatic will look in.

这篇关于为什么 collectstatic 不会复制我的静态文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆