python - Heroku+Django+Postgres error: "FATAL: database "python_getting_started" does not exist" -
i'm trying getting started python exercise @ heroku (https://devcenter.heroku.com/articles/getting-started-with-python#introduction). i'm following instructions , using git repo provided in tutorial. when go /db page of web app, uses database functionality, error trace:
environment: request method: request url: http://localhost:5000/db django version: 1.8.1 python version: 2.7.5 installed applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'hello') installed middleware: ('django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware', 'django.middleware.security.securitymiddleware') traceback: file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/users/lisha/desktop/starred_docs/python-getting-started/hello/views.py" in db 14. greeting.save() file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/models/base.py" in save 710. force_update=force_update, update_fields=update_fields) file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/models/base.py" in save_base 735. transaction.atomic(using=using, savepoint=false): file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/transaction.py" in __enter__ 150. if not connection.get_autocommit(): file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/backends/base/base.py" in get_autocommit 286. self.ensure_connection() file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/backends/base/base.py" in ensure_connection 130. self.connect() file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/utils.py" in __exit__ 97. six.reraise(dj_exc_type, dj_exc_value, traceback) file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/backends/base/base.py" in ensure_connection 130. self.connect() file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/backends/base/base.py" in connect 119. self.connection = self.get_new_connection(conn_params) file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py" in get_new_connection 172. connection = database.connect(**conn_params) file "/users/lisha/desktop/starred_docs/python-getting-started/venv/lib/python2.7/site-packages/psycopg2/__init__.py" in connect 164. conn = _connect(dsn, connection_factory=connection_factory, async=async) exception type: operationalerror @ /db exception value: fatal: database "python_getting_started" not exist
the crash when run app locally; app on herokuapp.com works fine. have idea problem might be? appreciated.
#try load local_settings.py if exists try: .settings_local import * except exception e: databases = { "default": { "engine": "django.db.backends.postgresql_psycopg2", } } import dj_database_url databases['default'] = dj_database_url.config() # honor 'x-forwarded-proto' header request.is_secure() secure_proxy_ssl_header = ('http_x_forwarded_proto', 'https') # allow host headers allowed_hosts = ['']
create settings_local.py
near settings.py
, declare database settings here
databases = { 'default': { 'engine': 'django.db.backends.postgresql_psycopg2', 'name': 'python_getting_started', 'user': 'some_postgre_user', 'password': 'some_password', } }
if don't have python_getting_started
have create it:
psql postgres create database python_getting_started; create user some_postgre_user password 'some_password'; grant on database python_getting_started some_postgre_user; \q
Comments
Post a Comment