Python 位于/目录的编程错误/
所以我正试图打开我的Heroku应用程序网站。将文件从git存储库推送到我的git heroku存储库后,我打开网站并收到此错误消息Python 位于/目录的编程错误/,python,python-3.x,django,heroku,Python,Python 3.x,Django,Heroku,所以我正试图打开我的Heroku应用程序网站。将文件从git存储库推送到我的git heroku存储库后,我打开网站并收到此错误消息 Environment: Request Method: GET Request URL: http://chimpbooks.herokuapp.com/catalog/ Django Version: 3.1.2 Python Version: 3.7.0 Installed Applications: ['django.contrib.admin',
Environment:
Request Method: GET
Request URL: http://chimpbooks.herokuapp.com/catalog/
Django Version: 3.1.2
Python Version: 3.7.0
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'catalog.apps.CatalogConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
The above exception (relation "catalog_book" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "catalog_book"
^
) was the direct cause of the following exception:
File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/app/catalog/views.py", line 11, in index
num_books = Book.objects.all().count()
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 411, in count
return self.query.get_count(using=self.db)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/query.py", line 515, in get_count
number = obj.get_aggregation(using, ['__count'])['__count']
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/query.py", line 500, in get_aggregation
result = compiler.execute_sql(SINGLE)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /catalog/
Exception Value: relation "catalog_book" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "catalog_book"
希望有人能帮我解决这个问题!希望能给这个网站添加更多的书,并尽快完成。谢谢!:) 您是否在Heroku上运行了
migrate
命令?PS看起来您已经打开了调试模式。出于安全原因,在生产过程中关闭该功能非常重要!您仍然可以在Heroku日志中看到任何错误的原因。我将Debug设置为False并再次推送存储库,但这一次出现了服务器错误(500)。您连接到了哪个数据库?如果您没有配置任何外部数据库,django有默认的DB配置,并且在存储中不是持久的,这意味着迁移也没有用……使用heroku的postgres数据库我该怎么做?对不起,我是新来heroku的