python manage.py collecstatic不会复制我的.css文件

编程入门 行业动态 更新时间:2024-10-27 02:30:36
本文介绍了python manage.py collecstatic不会复制我的.css文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试使用django中的静态文件。

我看过很多视频,我知道我觉得我做的正确。

以下是 settings.py 片段:

STATIC_URL ='/ static /' STATICFILES_DIR =(os.path.join(BASE_DIR,'static')) STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),'static_cdn')

我还将其添加到 urls.py :

if settings.DEBUG: urlpatterns + = static(settings.STATIC_URL,document_root = settings.STATIC_ROOT)

当我执行收藏,它会复制所有来自admin文件夹的文件。但是它不是从静态文件夹复制我的 .css 文件。有人可以告诉我我在哪里做错了。

解决方案

设置是 STATICFILES_DIRS ,带有S,因为它是一个列表的目录。

STATICFILES_DIRs =(os.path.join(BASE_DIR,'static'),)

I am trying to work with static files in django.

I have watched many videos and I know I feel I am doing it correctly.

Following is the settings.py snippet:

STATIC_URL = '/static/' STATICFILES_DIR = (os.path.join(BASE_DIR, 'static'),) STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_cdn')

I have also added this to urls.py:

if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

When I do a collectstatic it copies all those from admin folder. But it is not copying my .css file from static folder. Can someone tell me where am I doing it wrong.

解决方案

The setting is STATICFILES_DIRS, with an S, as it's a list of directories.

STATICFILES_DIRs = (os.path.join(BASE_DIR, 'static'),)

更多推荐

python manage.py collecstatic不会复制我的.css文件

本文发布于:2023-10-28 08:47:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536138.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   manage   python   py   css

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!