- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经制作了一个在我的服务器上运行的 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#using-a-different-wsgi-server) 中的哪些命令我仍然需要执行,哪些我可以跳过.
我还想知道在执行所有命令时我需要在哪个文件夹中
谢谢!
2012-09-06T21:44:52+00:00 app[web.1]: File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
2012-09-06T21:44:52+00:00 app[web.1]: File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
2012-09-06T21:44:52+00:00 app[web.1]: return getattr(connections[DEFAULT_DB_ALIAS], item)
2012-09-06T21:44:52+00:00 app[web.1]: backend = load_backend(db['ENGINE'])
2012-09-06T21:44:52+00:00 app[web.1]: File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line 24, in load_backend
2012-09-06T21:44:52+00:00 app[web.1]: return import_module('.base', backend_name)
2012-09-06T21:44:52+00:00 app[web.1]: File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
2012-09-06T21:44:52+00:00 app[web.1]: __import__(name)
2012-09-06T21:44:52+00:00 app[web.1]: File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 31, in <module>
2012-09-06T21:44:52+00:00 app[web.1]: raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
2012-09-06T21:44:52+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3
2012-09-06T21:44:54+00:00 heroku[web.1]: Process exited with status 1
2012-09-06T21:44:54+00:00 heroku[web.1]: State changed from starting to crashed
2012-09-06T21:44:54+00:00 heroku[web.1]: State changed from crashed to starting
2012-09-06T21:44:58+00:00 heroku[web.1]: Starting process with command `python ./manage.py runserver 0.0.0.0:57395 --noreload`
2012-09-06T21:44:59+00:00 app[web.1]: File "./manage.py", line 10, in <module>
设置.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 ,如果您再次阅读说明并按照说明进行操作,您将执行:
$pip install Django psycopg2 dj-database-url
接下来,配置应用程序以使用 Heroku 的 Postgres 数据库。安装的 dj-database-url 模块将从 env 自动执行所有操作。
将以下内容添加到您的 settings.py 中:
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
您可以在 settings.py 的末尾添加这些行以继续在本地使用 sql lite 并仅在 heroku 上使用 postgres。
settings.py
------------------------
import dj_database_url
import os
if os.getcwd() == "/app":
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
关于python - 如何在 Heroku 上启动你已经制作好的 Django 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12308046/
一段时间以来,我一直在做这个反复出现的噩梦(阅读 - 我的应用程序中的错误)。出于某种原因,某个计时器在我停止后继续发送“Elapsed”事件,即使 在事件本身 计时器“承认”已被禁用!检查一下: /
为了找到 2 个 git 分支的共同祖先,需要做的是: git merge-base branch another_branch 好的。但是……如果两个分支都已经 merge 了怎么办?当我在这种情况
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 1年前关闭。 Improve this
我想要一个相机 View ,可以将图像捕获到本地文件或让用户从本地照片库中选择图像。我想也许有人为此编写了很好的库/代码。也许我可以利用它。已经有好的了吗?谢谢。我只是避免重新发明轮子:) 最佳答案
我从 master 分支创建了一个功能分支。之后有来自功能分支的提交 [F1]。 [F1] -- Feature Branch / [M1]-[M2
我喜欢使用 .NET 进行编程,尤其是 C# 3.0、.NET 3.5 和 WPF。但我特别喜欢的是 Mono .NET 确实与平台无关。 现在我听说了 Mono 中的 Olive 项目。我找不到某种
介绍和搜索 所以我认为我犯了一个严重的错误,我很担心。我已经分析了独立负责人的论坛,我已经接近找到答案,但场景太具体,不适用于我所在的位置。如果您找到可以回答我的问题的特定主题,请链接我。 例如:Ho
我有一个类似于下图的提交图。标记为 * 的提交表示大量提交。 A* | B--------- | | C* D* master 和 cor
我喜欢使用 .NET 进行编程,尤其是 C# 3.0、.NET 3.5 和 WPF。但我特别喜欢的是 Mono .NET 确实与平台无关。 现在我听说了 Mono 中的 Olive 项目。我找不到某种
我们最近接手了一个 .NET 项目,在查看 db 后,我们在某些列中有以下内容: 1)某些列具有诸如" & etc etc 2) 有些有 标签和其他非 html 编码的标签 这些数据
你好,当我导航到应用程序中的另一个页面时出现此错误 我不知道为什么这个错误出现 #0 _AsyncCompleter.complete (dart:async/future_impl.da
我使用以下 C 算法计算数据的 CRC32: #define CRC32_POLYNOM_REVERSED 0xEDB88320 uint32 calcCrc32(uint8* buffer, u
我试图在我的一个测试中断言模型中的字段没有改变。我知道从哲学上这是不正确的,但由于我控制了我需要知道的所有变量,所以我只想检查我的数据库条目是否没有改变。 我愿意接受一个解决方案,该解决方案可以将其转
我是 GitHub 的新手。并通过 Eclipse 使用它我们是两个人在开发一个应用程序。当我在 Git shell 中检查 git status 时,我得到以下状态。 On branch maste
简单代码: std::ifstream file("file.txt"); std::string line; while(getline(file,line)) ; //exhaust file
是的,我又找不到这个 Gradle DSL 方法:'compile()' 问题。 我检查了我有: buildscript { repositories { jcenter()
HTML: articles CSS: #main_menu { float: left; padding-top: 10px; vertical-align: m
我是一名优秀的程序员,十分优秀!