失败的运行' collectstatic'将Django部署到Azure Web服务时,带有退出代码 -

发布于 2025-01-26 04:36:42 字数 1206 浏览 3 评论 0原文

我正在尝试将Django应用程序部署到Azure App Services。它现在在服务器上运行,但没有style.css。当我在localhost上运行它时,所有内容都用style.css正确显示。

这是我的项目结构:

voice-project -- app-- settings.py
                    -- wsgi.py
                    -- urls.py
                    -- manage.py
                    --db.sqlite3
                    -- asgi.py
             -- static
                 -- website
                    --style.css
             -- website
             -- .git

下面是我的设置。Py文件:

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATIC_URL = 'static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

这是部署日志中的collectstatic零件:

11:23:09 PM voicify: Running collectstatic...
11:23:12 PM voicify: 130 static files copied to '/tmp/8da2d7d5197a819/staticfiles'.
11:23:12 PM voicify: "2022-05-03 07:00:00"|WARNING|Failed running 'collectstatic' exited with exit code .

我不知道我在哪里可以找到造成运行的收集式错误,而且似乎不提供实际的退出代码。

此外,如果我将静态文件夹移至其他地方,例如在应用程序下或网站下,它会给我其他错误消息,说?:( staticfiles.w004)目录'/tmp/8da2d7971c62b0b/static'在staticfiles_dirs设置中不存在。

我觉得我唯一要做的就是将静态模式添加到url.pattern中。但是我觉得这也无法解决问题...

I am trying to deploy a Django app to Azure App Services. It runs on the server now, but without the style.css. When I run it on localhost, everything shows correctly with the style.css.

Here is my project structure:

voice-project -- app-- settings.py
                    -- wsgi.py
                    -- urls.py
                    -- manage.py
                    --db.sqlite3
                    -- asgi.py
             -- static
                 -- website
                    --style.css
             -- website
             -- .git

Below is my settings.py file:

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATIC_URL = 'static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

Here is the collectstatic part from the deployment log:

11:23:09 PM voicify: Running collectstatic...
11:23:12 PM voicify: 130 static files copied to '/tmp/8da2d7d5197a819/staticfiles'.
11:23:12 PM voicify: "2022-05-03 07:00:00"|WARNING|Failed running 'collectstatic' exited with exit code .

I don't know where I can find what caused the running collectstatic error, and it seems not to provide an actual exit code.

In addition, if I move the static folder to somewhere else, such as under app, or under website, it gives me additional error messages, saying ?: (staticfiles.W004) The directory '/tmp/8da2d7971c62b0b/static' in the STATICFILES_DIRS setting does not exist.

I feel the only left for me to to is to add the static pattern to the url.pattern. But I feel this also won't solve the problem...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文