我已经制作了一个在我的服务器上运行的django应用程序。我现在想用heroku在网上发布它,但是我发现的所有教程都会让你开始一个全新的项目。我不知道该怎么做来更新我已经存在的django项目来与heroku一起工作。在
我的文件现在是这样组织的:
in hcp:
crunchWeb:
crunchWeb: files = _init_.py ; settings.py ; urls.py ; wsgi.py
crunchApp: files = _init_.py ; admin.py ; models.py ; views.py etc...
manage.py
sqlite3.db
env: folders= bin ; helloflask ; include ; lib #all of these were created automatically
templates: all my .html files
我想知道heroku教程中的命令是什么(https://devcenter.heroku.com/articles/django\-a-different-wsgi-server)我还需要做什么,哪些可以跳过。在
我还想知道在执行所有命令时,我需要在哪个文件夹中
谢谢!在
^{pr2}$在设置.py在
# Django settings for crunchWeb project.
import dj_database_url
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
# {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
# 'NAME': '/Users/Santi/hcp/crunchWeb/sqlite3.db', # Or path to database file if using sqlite3.
# 'USER': '', # Not used with sqlite3.
# 'PASSWORD': '', # Not used with sqlite3.
# 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
# 'PORT': '', # Set to empty string for default. Not used with sqlite3.
# }
# }
直接从指示https://devcenter.heroku.com/articles/django开始,再次阅读并遵循这些说明,您将执行:
数据库设置
接下来,配置应用程序以使用Heroku的Postgres数据库。安装的dj数据库url模块将从env自动执行所有操作。在
将以下内容添加到设置.py公司名称:
^{pr2}$您可以在设置.py继续在本地使用sqllite,只在heroku上使用postgres。在
您链接的heroku/django deployment tutorial仍然是您的最佳选择。我刚刚部署了一个现有的应用程序,并跳过了我已经完成的步骤,例如:
基本上,如果你已经为你现有的应用干了这个!在
我没有看到要求.txt在上面的文件夹结构中确保
^{pr2}$为了减少破坏现有代码的可能性,我做了以下操作
push语句的最后一部分
heroku_test:master
允许您将本地分支heroku_test
推送到远程分支master
。(否则heroku将忽略提交,因为它不在主分支上)。在相关问题 更多 >
编程相关推荐