简体   繁体   English

Django和SSL服务器

[英]Django and SSL Server

I'm using a Django-SSLServer add-on with my Django app. 我在Django应用程序中使用Django-SSLServer加载项。 As found at: here 如在: 这里

For some reason when I run the server (using PyCharm), my static content doesn't render properly (if at all!). 由于某些原因,当我运行服务器(使用PyCharm)时,我的静态内容无法正确呈现(如果有的话!)。 However, when I run the built in HTTP server, it renders the static files fine. 但是,当我运行内置的HTTP服务器时,它可以很好地呈现静态文件。

How can I re-route my site so that static works for HTTPS? 如何重新路由我的站点,以使static适用于HTTPS? I'm using the built in server with Django. 我在Django中使用内置服务器。

Thanks! 谢谢!

Within your urls.py you should map your static path ie: 在urls.py中,您应该映射静态路径,即:

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

or alternatively, 或者,

from django.conf import settings
...
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': settings.STATIC_DOC_ROOT}),

This should render your settings files while DEBUG=False 这应该在DEBUG=False时呈现您的设置文件

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM