在制作django网站后不显示静态内容?

时间:2017-08-10 18:49:55

标签: python django

我暂时在pythonanywhere.com上托管了我的网站

但我不明白为什么静态内容没有显示。我在pythonanywhere.com上的settings.py是:

    STATIC_ROOT = u'/home/baqir/ProgrammersForum/main/static/'
STATIC_URL = '/static/'

在我的本地主机上是:

STATIC_URL = '/static/'

pythonanywhere.com的屏幕截图:

Website live

localhost上的屏幕截图:

On localhost

网址是正确的。我做错了什么?

PS:我还运行了python manage.py collectstatic

1 个答案:

答案 0 :(得分:-1)

进行这些更改。

Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/

<Directory /path/to/mysite.com/static>
Require all granted
</Directory>

<Directory /path/to/mysite.com/media>
Require all granted
</Directory>

Django Official Documentation Link