与REST API运行Django应用程序我刚刚创建的帐户上“Heroku.com”跟着指南中的步骤来创建一个新的Python项目。我在本地克隆了这些文件,并在项目中添加了一个新的应用程序,并创建了一个休息API。我说“rest_framework”我的“settings.py”我能够在本地运行项目。当我试图推动修改到Heroku的,它失败,我得到这个消息:当我从“settings.py”删除“rest_framework”我可以成功地把我的变化不能在Heroku
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 632 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing requirements with pip
remote:
remote: Package django found!
remote: -----> $ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "manage.py", line 10, in <module>
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python3.6/site-
packages/django/core/management/__init__.py", line 353, in
execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python3.6/site-
packages/django/core/management/__init__.py", line 327, in execute
remote: django.setup()
remote: File "/app/.heroku/python/lib/python3.6/site-
packages/django/__init__.py", line 18, in setup
remote: apps.populate(settings.INSTALLED_APPS)
remote: File "/app/.heroku/python/lib/python3.6/site-
packages/django/apps/registry.py", line 85, in populate
remote: app_config = AppConfig.create(entry)
remote: File "/app/.heroku/python/lib/python3.6/site-
packages/django/apps/config.py", line 90, in create
remote: module = import_module(entry)
remote: File
"/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in
import_module
remote: return _bootstrap._gcd_import(name[level:], package,
level)
remote: File "<frozen importlib._bootstrap>", line 978, in
_gcd_import
remote: File "<frozen importlib._bootstrap>", line 961, in
_find_and_load
remote: File "<frozen importlib._bootstrap>", line 948, in
_find_and_load_unlocked
remote: ModuleNotFoundError: No module named 'rest_framework'
remote:
remote: ! Error while running '$ python manage.py collectstatic --
noinput'.
remote: 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 xplearner.
remote:
To https://git.heroku.com/xplearner.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xplearner.git'
为“Heroku的”,但我没有更多的运行应用程序在本地,因为它不会在我的设置中找到restframework并在同一案件中,我得到这个错误,当我尝试在线推出在Heroku项目:
ModuleNotFoundError at /admin/
No module named 'rest_framework'
请某人建议这个问题的解决方案?我不正确的是什么?
它看起来像你忘了添加'rest_framework'到你的'requirements.txt'文件。你能向我们证明吗? – Chris
在PyPI中的BTW'rest_framework'被列为'djangorestframework'。 – Felicio
我没加restframework我requirements.txt文件。我刚刚做到了,我也必须将迁移应用到我的heroku应用程序,并且工作正常。非常感谢,我很欣赏。 –