Django的在Azure上不加载静态文件 [英] Django on Azure not loading static files
问题描述
我也跟着下面的教程创建在Azure上一个Django项目:
I followed the tutorial below to create a django project on azure:
<一个href=\"http://www.windowsazure.com/en-us/develop/python/tutorials/web-sites-with-django/\">http://www.windowsazure.com/en-us/develop/python/tutorials/web-sites-with-django/
一切工作正常,直到我试图安装django_admin_bootstrapped应用。现在,所有静态请求返回404错误。我不知道,如果新的应用程序导致的问题或者只是暴露了。
Everything worked fine until I tried to install the django_admin_bootstrapped app. Now all static requests return 404 error. I don't if the new app caused the problem or just exposed it.
我有这样的:
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
#os.path.join(PROJECT_DIR, 'site-packages/django_admin_bootstrapped/static'),
)
我在网上看了不少,有些人说你必须将服务器配置为静态文件。我没有对服务器的直接访问,这是一个蔚蓝色的网站,我通过git的部署。就像我说的,管理员和一切使用之前我试图安装这些应用程序,引导管理工作。现在,即使该应用程序是不是INSTALLED_APPS下我没有得到任何CSS或js文件。
I read quite a bit online and some people say you have to configure your server to serve static files. I don't have direct access to the server, it's an azure website and I deploy through git. And like I said, the admin and everything used to work before I tried to install these apps that bootstrap the admin. Now even when the app is not under INSTALLED_APPS I don't get any css or js files.
谢谢!
推荐答案
我有这个问题,并没有提出答案似乎适合。我奇怪的解决办法是的关闭的Python中的Azure配置网站页面上。
I had this problem and none of the suggested answers seemed to fit. My bizarre solution was to switch off Python on the Azure web site configure page.
我来到这个奇怪的结论,在本教程中的http://azure.microsoft.com/en-us/documentation/articles/web-sites-python-ptvs-django-sql/.唯一的区别我可以我的网站和工作之间的教程罚款是Django的被关!如果有人有一个解释我很想听到它(PHP启用了!!!)。
I arrived at this odd conclusion by installing the PTVS Django sample and following the steps in this tutorial http://azure.microsoft.com/en-us/documentation/articles/web-sites-python-ptvs-django-sql/. The only difference I could fine between my site and the working tutorial was that Django was off! If someone has an explanation I would love to hear it (PHP is enabled!!!).
这篇关于Django的在Azure上不加载静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!