我正在嘗試上傳我的第一個 django 應用程式,我一直在努力解決這個問題,感謝您的幫助。
我已經將我的專案設定在 heroku 上,我按照本教程進行操作:https ://www.youtube.com/watch?v=6DI_7Zja8Zc其中django_heroku 模塊用于配置 DB,這里是庫的鏈接https:// /pypi.org/project/django-heroku/
該應用程式在登錄時引發錯誤,就好像用戶表不存在但我已經使用 heroku bash 功能創建了一個超級用戶,在使用“heroku run python manage.py migrate”應用遷移之后。當我在 heroku bash 上運行“ls”命令時,這是我的目錄:
manage.py Procfile requirements.txt runtime.txt 煙霧靜態檔案
“smoke”是我的檔案夾應用程式,我應該在這個目錄中看到資料庫嗎?如果未創建資料庫,我如何使用 heroku bash 功能創建超級用戶?
這是 django 在服務器上給我的資料庫配置:
{'default': {'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_MAX_AGE': 0,
'ENGINE': 'django.db.backends.sqlite3',
'HOST': '',
'NAME': PosixPath('/app/db.sqlite3'),
'OPTIONS': {},
'PASSWORD': '********************',
'PORT': '',
'TEST': {'CHARSET': None,
'COLLATION': None,
'MIGRATE': True,
'MIRROR': None,
'NAME': None},
'TIME_ZONE': None,
'USER': ''}}
我看到 db 是 sqlite3 并且應該是 postgreSQL 但我知道 django-heroku 庫應該這樣做。
我不知道還有哪些其他資訊可能有用,因為我沒有部署任何內容的經驗,因此我將等待更多資訊請求以編輯此問題。
我的 gitignore 檔案是這樣的:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
這是我的 settings.py 檔案的底部:
...
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfile')
STATIC_URL = '/static/'
django_heroku.settings(locals())
謝謝你。
uj5u.com熱心網友回復:
如果您查看GitHub 上的django-heroku存盤庫,我想您會發現它已被廢棄。它有一個橫幅說
此存盤庫已由所有者存檔。它現在是只讀的。
master并且自 2018 年 10 月以來沒有在分支上進行新的提交。
該heroku-on-django庫旨在成為以下內容的更新替代品django-heroku:
這是從django-heroku派生出來的,因為它被放棄了,然后因為舊專案已存檔而重命名為django-on-heroku 。
它也有些停滯(撰寫本文時最近的承諾master是從 2020 年 10 月開始),但它應該比django-heroku.
無論哪種情況,請確保settings.py按照檔案中的說明將其放在您的底部:
# Configure Django App for Heroku.
import django_on_heroku
django_on_heroku.settings(locals())
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/414657.html
標籤:
下一篇:linux比較兩個變數
