首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法部署Heroku,因为Python包出错

无法部署Heroku,因为Python包出错
EN

Stack Overflow用户
提问于 2019-02-28 10:46:45
回答 1查看 270关注 0票数 1

我正试着在Heroku上上传我的django应用程序。它在本地可以工作,因为我纠正了错误,但由于某种原因,我添加了whitenoise来获取本地文件,以便可以在Heroku上部署,但它总是出现相同的错误。我正在加载一个本地包csv-imports,它在第70行有一个错误。

代码语言:javascript
复制
class ImportModel(models.Model):
    """ Optional one to one mapper of import file to Model """
    #this is the line with the error and I fixed it here with the on_delete
    csvimport = models.ForeignKey(CSVImport, on_delete=models.DO_NOTHING)
    numeric_id = models.PositiveIntegerField()
    natural_key = models.CharField(max_length=100)

但是,当我运行以下命令时:

代码语言:javascript
复制
git push heroku master

我得到了以下错误,我已经修复了我的本地,但似乎不断出现Heroku。文件已更改。我可能没有在Heroku给出的正确文件路径上,我的计算机上没有应用程序/.heroku/。但是,在我的电脑上只有一个csv-imports的安装,而且那个已经被修复了。为什么我一直收到这个错误,我如何修复它?

代码语言:javascript
复制
remote:          File "/app/.heroku/python/lib/python3.7/site-packages/csvimport/models.py", line 72, in ImportModel
remote:            csvimport = models.ForeignKey(CSVImport)
remote:        TypeError: __init__() missing 1 required positional argument: 'on_delete'
remote: 
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
emote:        See traceback above for details.
remote: 
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote: 
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote: 
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to gentle-lowlands-98196.
remote: 
EN

回答 1

Stack Overflow用户

发布于 2019-03-03 11:38:53

如果你的静态目录有问题,首先你必须运行:"python manage.py“这会给你静态目录的路径,或者是一个异常,就像你使用没有STATIC_ROOT目录的STATIC_URL。

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

https://stackoverflow.com/questions/54917645

复制
相关文章

相似问题

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