Django无法在Heroku上迁移

时间:2019-04-14 16:12:15

标签: python django heroku

我在尝试运行heroku run python manage.py migrate时在Heroku上迁移数据库时遇到问题。我总是会收到此错误:

(venv) E:\Studia\advise\promotion>heroku run python manage.py migrate
Running python manage.py migrate on ⬢ pro-motion... up, run.6349 (Free)
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 325, in execute
    settings.INSTALLED_APPS
  File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/promotion/settings.py", line 27, in <module>
    DEBUG = config('DEBUG', default=False, cast=bool)
  File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 197, in __call__
    return self.config(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 85, in __call__
    return self.get(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 79, in get
    return cast(value)
  File "/app/.heroku/python/lib/python3.6/site-packages/decouple.py", line 50, in _cast_boolean
    raise ValueError('Not a boolean: %s' % value)
ValueError: Not a boolean: True

Heroku config

1 个答案:

答案 0 :(得分:0)

Your screenshot shows a DEBUG environment variable whose value contains extra whitespace.

Depending on how you use that variable, the whitespace could easily caus problems. Delete that extra whitespace and see if that fixes things.


Also, you've partly revealed your SECRET_KEY and PostgreSQL credentials. Please change the SECRET_KEY and rotate your database credentials. Your current values are no longer secure.