首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nvd3相关的'Get‘请求在演示项目中失败了吗?

nvd3相关的'Get‘请求在演示项目中失败了吗?
EN

Stack Overflow用户
提问于 2014-06-17 07:24:46
回答 1查看 446关注 0票数 1

我正在运行django-nvd3演示项目,并且看到没有显示饼图。我看到以下请求失败

代码语言:javascript
复制
GET http://localhost:8000/static/nvd3/src/nv.d3.css
GET http://localhost:8000/static/nvd3/src/nv.d3.css  show_graph:3
GET http://localhost:8000/static/nvd3/nv.d3.min.js  show_graph:5
GET http://localhost:8000/static/d3/d3.min.js 

我已经安装了python-nvd3和它的所有依赖项。以下是我的设置文件配置

代码语言:javascript
复制
    BASE_DIR = dirname(dirname(__file__))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = join(BASE_DIR, 'static')

BOWER_COMPONENTS_ROOT = join(BASE_DIR, 'components')

# 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.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
    'djangobower.finders.BowerFinder',
)

BOWER_INSTALLED_APPS = ( 
    'jquery', 
    'underscore', 
    'd3#3.3.6', 
    'nvd3#1.1.12-beta', 
)

我错过了什么??

EN

回答 1

Stack Overflow用户

发布于 2014-06-17 07:52:30

在生产环境中,您必须使用您选择的you服务器提供静态文件。设置中的注释表示您正在运行开发服务器。在这种情况下,将'django.contrib.staticfiles'添加到已安装的应用程序中就足够了。当为DEBUG = True时,staticfiles应用程序将使用python流式传输响应,自动提供在STATICFILES_DIRS或各种STATICFILES_FINDERS中找到的静态文件。

不要在生产环境中使用它,因为它的效率很低,而且可能不安全。

相反,使用您的etc服务器(Apache、IIS、gunicorn等)为静态文件提供服务。collectstatic管理命令会将所有静态文件收集到一个中心位置(您的STATIC_ROOT)。然后设置您的set服务器以提供来自此位置的静态文件。

有关如何做到这一点的更多信息可以在'Deploying static files'和您的the服务器的文档中找到。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24253643

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档