【问题标题】:How to Deploy D3 in Heroku (Django App)?如何在 Heroku(Django 应用程序)中部署 D3?
【发布时间】:2016-05-02 04:20:56
【问题描述】:

我正在尝试为 yahoo 财务创建数据可视化,我已使用 Django 1.9.2 在本地成功完成了该操作。它抓取 yahoo 的财务信息,然后使用 D3 创建带有工具提示的气泡图。 但是,气泡没有出现: https://pure-woodland-72284.herokuapp.com/ 这是出现在 Heroku 日志中的内容。 Heroku Log Error Messages

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework_swagger', 'mysite' ) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates',

    'DIRS': [
        # insert your TEMPLATE_DIRS here
            os.path.join(os.path.dirname(__file__), 'templates'),

    ],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
            # list if you haven't customized them:
            'django.contrib.auth.context_processors.auth',
            'django.template.context_processors.debug',
            'django.template.context_processors.i18n',
            'django.template.context_processors.media',
            'django.template.context_processors.static',
            'django.template.context_processors.tz',
            'django.contrib.messages.context_processors.messages',
        ],
    },
},

]

REST_FRAMEWORK={ 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ] }

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',

)

【问题讨论】:

    标签: django heroku d3.js deployment visualization


    【解决方案1】:

    您的控制台出现以下错误:

    Mixed Content: The page at 'https://pure-woodland-72284.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://fonts.googleapis.com/css?family=Lobster+Two:400,700italic'. This request has been blocked; the content must be served over HTTPS.
    

    因此您收到 'Uncaught ReferenceError: $ is not defined' 错误,因为您并没有真正导入您的库

    所以我猜你已经从他们的 cdn 导入了你的脚本(jquery、d3.tip、cssfonts)并在导入时使用了 http。尝试使用 https 导入它们,看看是否能解决您的问题

    【讨论】:

      猜你喜欢
      • 2011-12-05
      • 2018-10-18
      • 2017-12-01
      • 2020-04-24
      • 1970-01-01
      • 2016-11-16
      • 2021-04-28
      • 2017-09-20
      相关资源
      最近更新 更多