Django 静态文件无法在 cpanel 上运行

问题描述 投票:0回答:1

我的settings.py静态设置是

STATIC_URL = 'static/'
STATIC_ROOT = '/home/mywebsite/public_html/dj/static/'

我已成功运行:manage.pycollectstatic。
我重新启动了应用程序。
但是当我点击 URL

http://mywebsite/admin
时,没有 CSS。

也许某个地方与 .htaccess 有关。 我需要帮助

附注我正在使用带有 cPanel 的共享主机,但没有终端访问权限

django cpanel django-deployment
1个回答
0
投票

我通过在 public_html 中创建一个名为 static 的目录并手动或使用管理collectstatic 将所有静态文件放在那里解决了这个问题。
所以而不是

STATIC_ROOT = '/home/mywebsite/public_html/dj/static/'``` 
I made 

STATIC_ROOT = '/home/mywebsite/public_html/static/'

In other words the static folder needs to be directly inside public_html and not inside another folder. I don't know wether this is a general rule for cPanel or just happened in my configuration.
© www.soinside.com 2019 - 2024. All rights reserved.