【问题标题】:Issues deploying django-nvd3 charts on heroku在 heroku 上部署 django-nvd3 图表的问题
【发布时间】:2014-04-14 15:55:31
【问题描述】:

最近有人尝试成功地将 django-nvd3 图表部署到 Heroku 上吗?整个周末我都在尝试使用 nvd3 图表将 django 应用程序部署到 heroku,但没有成功。它在我的开发环境(ubuntu)中运行良好。但是,当我尝试将其推送到 Heroku 时,遇到了各种错误。

在开发环境中,我安装了 npm(包括 node.js),后来安装了 bower,最后安装了 django-bower;正如https://github.com/areski/django-nvd3 所建议的那样。我尝试了不同的图表,一切正常,没有问题

但是,当我尝试将代码推送到 Heroku 时,我遇到了很多错误。修复一个会导致其他人。我想知道,如果我首先需要将 package.json(列出诸如 bower 之类的 npm 依赖项)和 bower.json(列出诸如 d3、nvd3 之类的 bower 依赖项)文件添加到我的存储库中?

我在 Google 上搜索了很多提供枪击信息的文档(django、nvd3、bower、npm/node 都结合在一起),但没有看到任何

注意:我将尝试发布 heroku 日志以获取更多信息。

bower.json 是这样的:

{
"dependencies": {    
    "d3": "3.3.6",
    "nvd3": "1.1.12-beta"  
}

package.json 是这样的:

"engines": {    
    "node": "0.11.11",    
    "npm": "1.3.25"    
 },  
"dependencies": {    
    "bower": "1.3.1"    
 }

我遇到的错误是这样的:

1. gunicorn is not recognized - resolved this
2. NameError: Name 'DATABASES' is not defined in settings.py - resolved this
3. django.core.management is not found - resolved this
4. Git error: fatal: HEAD corrupted/ cannot be deployed on to heroku - resolved this
5. listening at localhost 127.0.0.1:8000 - am working on this. I think this is also to do with my DATABASES setting that is pointing at dj_database_url.config(default=['DATABASE_URL'])??

是否有任何带有django+nvd3charts 的 Git 存储库已成功部署到 Heroku?我可以看看配置吗?

也在看https://github.com/areski/django-nvd3;我没有看到这里列出的任何 bower 依赖项或 npm 依赖项,它是这样工作的吗?

或者,Heroku 是否可以在没有 package.json 的情况下自动安装 npm/bower,也可以查看 settings.py 文件并通过查看 bower 依赖项,Heroku 是否也可以安装这些依赖项而不需要 bower.json 文件来专门将 d3、nvd3 列为依赖项?据我所知,我想不是这样的

请推荐

【问题讨论】:

  • 我现在开始使用谷歌图表,它的作用就像一个魅力。部署也没有问题。甚至没有一个麻烦..非常感谢

标签: django heroku npm bower nvd3.js


【解决方案1】:

我写了一篇关于这个的博客文章,你可以在这里找到:https://mattdoesstuff.wordpress.com/2015/04/10/getting-npm-d3-nvd3-django-bower-django-bower-nvd3-and-heroku-to-play-nicely-together/

使用 django-nvd3 和 django-bower

pip install django-nvd3 django-bower
pip freeze > requirements.txt
git add .
git commit -m "don't forget your requirements.txt!"

使用多构建包

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

同时使用 Node 和 Python 构建包

# ./.buildpacks
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/amanjain/heroku-buildpack-python-with-django-bower.git

使用 npm 下载 bower

# ./package.json
{"private": true,"dependencies": {"bower": "1.4.1"}}

用户 django-bower 收集其资产

# ./bin/post_compile
# install bower components
./manage.py bower_install

告诉 django 在哪里可以找到凉亭

# settings.py
...
import os

APPLICATION_DIR = os.path.dirname(globals()['__file__'])
HEROKU = bool(os.environ.get('DATABASE_URL'))

BOWER_COMPONENTS_ROOT = os.path.join(APPLICATION_DIR, 'components')

# where to find your local bower
BOWER_PATH = '/usr/local/bin/bower'

if HEROKU:
    BOWER_PATH = '/app/node_modules/bower/bin/bower'

BOWER_INSTALLED_APPS = (
    'd3#3.3.13',
    'nvd3#1.7.1',
)
...

学分 * http://www.rawsrc.com/using-django-bower-on-heroku/ * https://github.com/ddollar/heroku-buildpack-multi.git * https://github.com/areski/django-nvd3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-16
    • 2021-11-16
    • 2022-09-30
    • 2019-08-05
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 2017-06-24
    相关资源
    最近更新 更多