访问被拒绝使用Python / Django在Heroku的ClearDB数据库 [英] Access denied to ClearDB database using Python/Django on Heroku

查看:320
本文介绍了访问被拒绝使用Python / Django在Heroku的ClearDB数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python / Django在Heroku上构建一个webapp,我只是按照教程设置一个Django项目并将其推送到Heroku。但是,我甚至永远不会去正常的Django它的工作!屏幕。当然,这是因为当我检查 heroku ps 时,从来没有任何进程正在运行。没有 Procfile ,但根据教程,对于Django应用程序来说,这并不重要。

I'm trying to build a webapp on Heroku using Python/Django, and I just followed the tutorial to set up a Django project and push it to Heroku. However, I can never even get to the normal Django "It worked!" screen. Of course, that is because when I check heroku ps, there are never any processes running. There is no Procfile but according to the tutorial, that shouldn't matter for a Django app.

当我运行 heroku运行python manage.py runserver ,出现以下错误:

When I run heroku run python manage.py runserver, the following error occurs:

Unhandled exception in thread started by <bound method Command.inner_run of <dja
ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x1ff819
0>>
Traceback (most recent call last):
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/com
mands/runserver.py", line 91, in inner_run
    self.validate(display_num_errors=True)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/val
idation.py", line 103, in get_validation_errors
    connection.validation.validate_field(e, opts, f)
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/mysql/v
alidation.py", line 14, in validate_field
    db_version = self.connection.get_server_version()
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/mysql/b
ase.py", line 411, in get_server_version
    self.cursor()
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/__init_
_.py", line 306, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/mysql/b
ase.py", line 387, in _cursor
    self.connection = Database.connect(**kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/MySQLdb/__init__.py", line
 81, in Connect
    return Connection(*args, **kwargs)
  File "/app/.heroku/venv/lib/python2.7/site-packages/MySQLdb/connections.py", l
ine 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1044, "Access denied for user '<user>
'@'%' to database 'heroku_<####################>?reconnect=true'")

我已经将我的 DATABASE_URL 设置为 CLEARDB_DATABASE_URL 另外,在Django settings.py 中,我按照指示添加:

I did already set my DATABASE_URL to the value of CLEARDB_DATABASE_URL. Also, in the Django settings.py, I added as instructed:

import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}

任何帮助将不胜感激。

推荐答案

调用ClearDB后,这个特定的错误是固定的,结果是?reconnect = true 仅适用于Rails应用程序,应该从 DATABASE_URL 为Django应用程序。

That particular error was fixed after calling ClearDB. Turns out that the ?reconnect=true is only for Rails apps, and should be removed from the DATABASE_URL for Django apps.

这篇关于访问被拒绝使用Python / Django在Heroku的ClearDB数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆