Django在Azure上不加载静态文件 [英] Django on Azure not loading static files

查看:123
本文介绍了Django在Azure上不加载静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循下面的教程,在天蓝色上创建一个django项目:

I followed the tutorial below to create a django project on azure:

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.

谢谢!

推荐答案

我有这个问题,没有一个建议的答案似乎适合。我的奇怪的解决方案是在Azure网站配置页面上关闭 Python。

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.

我通过安装PTVS Django示例获得了这个奇怪的结论,并按照本教程中的步骤 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆