Deploy Python project to Heroku with error

Asked

Viewed 311 times

0

I’m trying to deploy a Python project using Django on Heroku. deploy is fine, but when trying to do heroku run python manage.py migrate the following error occurs.

Traceback (most recent call last):
File "manage.py", line 23, in <module>
  execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
  utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 317, in execute
  settings.INSTALLED_APPS
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
  self._setup(name)
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
  self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 106, 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/djangosige/configs/__init__.py", line 3, in <module>
  from .settings import *
File "/app/djangosige/configs/settings.py", line 4, in <module>
  from .configs import DEFAULT_DATABASE_URL, DEFAULT_FROM_EMAIL, EMAIL_HOST, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD, EMAIL_PORT, EMAIL_USE_TLS
ModuleNotFoundError: No module named 'djangosige.configs.configs'

This is my configs.py file

# Configuração da base de dados

# Caso seja deixado vazio o default será: 'sqlite:////...djangosige/db.sqlite3'
DEFAULT_DATABASE_URL = 'postgres://meuuser:minhasenhadbc@localhost/nomebd'

# Configurações do servidor de email

# Endereço de email padrão utilizado

DEFAULT_FROM_EMAIL = '[email protected]'

EMAIL_HOST = 'smtp.gmail.com'  # Gmail
# EMAIL_HOST = 'smtp.live.com' #Hotmail

# Usuário do email padrão
EMAIL_HOST_USER = 'meuuser'

# Senha do email padrão
EMAIL_HOST_PASSWORD = 'minhasenha'

# Verificar a port utilizada pelo serviço de email
EMAIL_PORT = 587

EMAIL_USE_TLS = True

Does anyone know what might be going on?

2 answers

0

I would indicate using an api for postgresql dj-database-url and configure the email server in the same directly in the Settings.
For me never gave problems!

import dj_database_url

    DATABASES = {
        'default': dj_database_url.config()
    }

EMAIL_BACKEND ='Django.core.mail.backends.console.Emailbackend'

EMAIL_HOST =""
EMAIL_HOST_USER = ""
EMAIL_PORT = 3386
EMAIL_USER_TLS = True
EMAIL_HOST_PASSWORD = ""
DEFAULT_FROM_EMAIL = ""

0

Interpreting the error message:

You have the module:

/app/djangosige/configs/__init__.py

On line 3 of this file Voce makes an import

from .settings import *

That runs successfully, with the asteriskVoce imports everything implicitly, practice not recommended by PEP 20 (Explicit is Better than implicit.), in that import the file settings.pyis loaded and in its line 4 vc makes import:

from .configs import DEFAULT_DATABASE_URL, DEFAULT_FROM_EMAIL,....

That is, Voce this in /app/djangosige/configs/making import of the config module that does not exist. Hence the error message: No module named 'djangosige.configs.configs'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.