gpt4 book ai didi

python - Django 支持生产静态文件

转载 作者:太空宇宙 更新时间:2023-11-04 05:22:47 25 4
gpt4 key购买 nike

<分区>

在我的 settings.py 中,

STATIC_ROOT = '/home/khantthulinn/webapps/static_media/'
STATIC_URL = '/home/khantthulinn/webapps/static_media/'

在我的 urls.py 中,

urlpatterns = patterns('',

url(r'^admin/', admin.site.urls),

#Media
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT}),

)+ static(settings.STATIC_ROOT, document_root=settings.STATIC_ROOT)

之后,在我的网络服务器中,我复制了静态文件。

python manage.py collectstatic

一切都很好,我看得很正确。

当我更改 DEBUG = False 时,问题就来了。

我已经读过了,但我不明白。

https://docs.djangoproject.com/en/1.10/howto/static-files/deployment/

我也从这里阅读了解决方案。

Why does DEBUG=False setting make my django Static Files Access fail?

With debug turned off Django won't handle static files for you any more - your production web server (Apache or something) should take care of that.

我想试试。我该怎么办?

我不想运行它,因为它不安全。

manage.py runserver --insecure

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com