我在Heroku上部署了我的geodjango网站,除了:
之外它有效网站未显示数据库中的任何数据。
迁移到Heroku顺利进行:
Running python manage.py migrate on ⬢ countrycompare... up, run.5217 (Free)
Operations to perform:
Apply all migrations: admin, auth, compare, contenttypes, flatpages, sessions, sites
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying compare.0001_initial... OK
Applying compare.0002_remove_worldborder_geom... OK
Applying compare.0003_auto_20180422_1605... OK
Applying sites.0001_initial... OK
Applying flatpages.0001_initial... OK
Applying sessions.0001_initial... OK
Applying sites.0002_alter_domain_unique... OK
当我查看postgis数据库时,数据就在那里:
heroku pg:psql
--> Connecting to postgresql-clean-31400
psql (9.6.6, server 10.3 (Ubuntu 10.3-1.pgdg16.04+1))
WARNING: psql major version 9.6, server major version 10.
Some psql features might not work.
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
countrycompare::DATABASE=> \dt
List of relations
Schema | Name | Type | Owner
--------+----------------------------+-------+----------------
public | auth_group | table | wfmqwxgtkefsjo
public | auth_group_permissions | table | wfmqwxgtkefsjo
public | auth_permission | table | wfmqwxgtkefsjo
public | auth_user | table | wfmqwxgtkefsjo
public | auth_user_groups | table | wfmqwxgtkefsjo
public | auth_user_user_permissions | table | wfmqwxgtkefsjo
public | compare_worldborder | table | wfmqwxgtkefsjo
public | django_admin_log | table | wfmqwxgtkefsjo
public | django_content_type | table | wfmqwxgtkefsjo
public | django_flatpage | table | wfmqwxgtkefsjo
public | django_flatpage_sites | table | wfmqwxgtkefsjo
public | django_migrations | table | wfmqwxgtkefsjo
public | django_session | table | wfmqwxgtkefsjo
public | django_site | table | wfmqwxgtkefsjo
public | spatial_ref_sys | table | wfmqwxgtkefsjo
(15 rows)
但是当我访问网站(http://countrycompare.herokuapp.com)时,所有存储在数据库中的内容都将丢失。
我该如何解决这个问题?
这是我的数据库连接设置:
import dj_database_url
DATABASES = { 'default': dj_database_url.config(
default = 'postgis://wfmqwxgtkefsjo:24da873c123456bfbdfe594ce47e98e8328241aa3eafdf34a989295c207ffc0a@ec2-174-129-41-64.compute-1.amazonaws.com:5432/denspee4q3d4il'
)
}
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
我已经设定
heroku config:set BUILD_WITH_GEO_LIBRARIES=1
使用cedar-stack 14(16还不支持geo库)。
非常感谢任何帮助!