0

I have successfully deployed Python/Django app called MyPortfolio in Heroku. But when I am trying to open it gives me an error: ModuleNotFoundError: No module named 'jobs'
The project folder is MeryPortfolio-project. The project name is MeryPortfolio. Application name is jobs. So Heroku can't find the module for the application.

The case is: I have tried to make local and production settings. Local settings I use when I start the local server. Production settings are used in Heroku with the command:

heroku config:set DJANGO_SETTINGS_MODULE=MeryPortfolio-project.MeryPortfolio.settings.production

The directories are:

'MeryPortfolio-project'
    /'MeryPortfolio':
        ___init__.py
        settings.py
        urls.py
        wsgi.py
        /settings:
            __init__.py
            base.py
            local.py
            production.py

These are logs when I try to open the app (heroku open)

$ heroku logs
2019-07-18T12:54:14.328455+00:00 app[web.1]: spew: False
2019-07-18T12:54:14.328457+00:00 app[web.1]: check_config: False
2019-07-18T12:54:14.328459+00:00 app[web.1]: preload_app: True
2019-07-18T12:54:14.328461+00:00 app[web.1]: sendfile: None
2019-07-18T12:54:14.328463+00:00 app[web.1]: reuse_port: False
2019-07-18T12:54:14.328465+00:00 app[web.1]: chdir: /app
2019-07-18T12:54:14.328467+00:00 app[web.1]: daemon: False
2019-07-18T12:54:14.328469+00:00 app[web.1]: raw_env: []
2019-07-18T12:54:14.328471+00:00 app[web.1]: pidfile: None
2019-07-18T12:54:14.328472+00:00 app[web.1]: worker_tmp_dir: None
2019-07-18T12:54:14.328474+00:00 app[web.1]: user: 36932
2019-07-18T12:54:14.328476+00:00 app[web.1]: group: 36932
2019-07-18T12:54:14.328479+00:00 app[web.1]: umask: 0
2019-07-18T12:54:14.328481+00:00 app[web.1]: initgroups: False
2019-07-18T12:54:14.328483+00:00 app[web.1]: tmp_upload_dir: None
2019-07-18T12:54:14.328485+00:00 app[web.1]: secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
2019-07-18T12:54:14.328487+00:00 app[web.1]: forwarded_allow_ips: ['*']
2019-07-18T12:54:14.328489+00:00 app[web.1]: accesslog: -
2019-07-18T12:54:14.328491+00:00 app[web.1]: disable_redirect_access_to_syslog: False
2019-07-18T12:54:14.328494+00:00 app[web.1]: access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
2019-07-18T12:54:14.328496+00:00 app[web.1]: errorlog: -
2019-07-18T12:54:14.328498+00:00 app[web.1]: loglevel: debug
2019-07-18T12:54:14.328500+00:00 app[web.1]: capture_output: False
2019-07-18T12:54:14.328502+00:00 app[web.1]: logger_class: gunicorn.glogging.Logger
2019-07-18T12:54:14.328504+00:00 app[web.1]: logconfig: None
2019-07-18T12:54:14.328505+00:00 app[web.1]: logconfig_dict: {}
2019-07-18T12:54:14.328507+00:00 app[web.1]: syslog_addr: udp://localhost:514
2019-07-18T12:54:14.328509+00:00 app[web.1]: syslog: False
2019-07-18T12:54:14.328511+00:00 app[web.1]: syslog_prefix: None
2019-07-18T12:54:14.328513+00:00 app[web.1]: syslog_facility: user
2019-07-18T12:54:14.328515+00:00 app[web.1]: enable_stdio_inheritance: False
2019-07-18T12:54:14.328517+00:00 app[web.1]: statsd_host: None
2019-07-18T12:54:14.328519+00:00 app[web.1]: statsd_prefix:
2019-07-18T12:54:14.328521+00:00 app[web.1]: proc_name: None
2019-07-18T12:54:14.328524+00:00 app[web.1]: default_proc_name: MeryPortfolio-project.MeryPortfolio.wsgi:jobs
2019-07-18T12:54:14.328526+00:00 app[web.1]: pythonpath: None
2019-07-18T12:54:14.328528+00:00 app[web.1]: paste: None
2019-07-18T12:54:14.328530+00:00 app[web.1]: on_starting: <function OnStarting.on_starting at 0x7f26b45c90d0>
2019-07-18T12:54:14.328532+00:00 app[web.1]: on_reload: <function OnReload.on_reload at 0x7f26b45c91e0>
2019-07-18T12:54:14.328535+00:00 app[web.1]: when_ready: <function WhenReady.when_ready at 0x7f26b45c92f0>
2019-07-18T12:54:14.328536+00:00 app[web.1]: pre_fork: <function Prefork.pre_fork at 0x7f26b45c9400>
2019-07-18T12:54:14.328539+00:00 app[web.1]: post_fork: <function Postfork.post_fork at 0x7f26b45c9510>
2019-07-18T12:54:14.328541+00:00 app[web.1]: post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f26b45c9620>
2019-07-18T12:54:14.328542+00:00 app[web.1]: worker_int: <function WorkerInt.worker_int at 0x7f26b45c9730>
2019-07-18T12:54:14.328544+00:00 app[web.1]: worker_abort: <function WorkerAbort.worker_abort at 0x7f26b45c9840>
2019-07-18T12:54:14.328546+00:00 app[web.1]: pre_exec: <function PreExec.pre_exec at 0x7f26b45c9950>
2019-07-18T12:54:14.328549+00:00 app[web.1]: pre_request: <function PreRequest.pre_request at 0x7f26b45c9a60>
2019-07-18T12:54:14.328551+00:00 app[web.1]: post_request: <function PostRequest.post_request at 0x7f26b45c9ae8>
2019-07-18T12:54:14.328552+00:00 app[web.1]: child_exit: <function ChildExit.child_exit at 0x7f26b45c9bf8>
2019-07-18T12:54:14.328554+00:00 app[web.1]: worker_exit: <function WorkerExit.worker_exit at 0x7f26b45c9d08>
2019-07-18T12:54:14.328557+00:00 app[web.1]: nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f26b45c9e18>
2019-07-18T12:54:14.328558+00:00 app[web.1]: on_exit: <function OnExit.on_exit at 0x7f26b45c9f28>
2019-07-18T12:54:14.328561+00:00 app[web.1]: proxy_protocol: False
2019-07-18T12:54:14.328563+00:00 app[web.1]: proxy_allow_ips: ['127.0.0.1']
2019-07-18T12:54:14.328565+00:00 app[web.1]: keyfile: None
2019-07-18T12:54:14.328567+00:00 app[web.1]: certfile: None
2019-07-18T12:54:14.328569+00:00 app[web.1]: ssl_version: 2
2019-07-18T12:54:14.328571+00:00 app[web.1]: cert_reqs: 0
2019-07-18T12:54:14.328573+00:00 app[web.1]: ca_certs: None
2019-07-18T12:54:14.328575+00:00 app[web.1]: suppress_ragged_eofs: True
2019-07-18T12:54:14.328577+00:00 app[web.1]: do_handshake_on_connect: False
2019-07-18T12:54:14.328579+00:00 app[web.1]: ciphers: TLSv1
2019-07-18T12:54:14.328581+00:00 app[web.1]: raw_paste_global_conf: []
2019-07-18T12:54:14.741538+00:00 app[web.1]: Traceback (most recent call last):
2019-07-18T12:54:14.741609+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2019-07-18T12:54:14.742160+00:00 app[web.1]: sys.exit(run())
2019-07-18T12:54:14.742163+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
2019-07-18T12:54:14.742165+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2019-07-18T12:54:14.742167+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 223, in run
2019-07-18T12:54:14.742169+00:00 app[web.1]: super(Application, self).run()
2019-07-18T12:54:14.742175+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 72, in run
2019-07-18T12:54:14.745026+00:00 app[web.1]: Arbiter(self).run()
2019-07-18T12:54:14.745029+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 60, in __init__
2019-07-18T12:54:14.745031+00:00 app[web.1]: self.setup(app)
2019-07-18T12:54:14.745033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 120, in setup
2019-07-18T12:54:14.745035+00:00 app[web.1]: self.app.wsgi()
2019-07-18T12:54:14.745037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-18T12:54:14.745039+00:00 app[web.1]: self.callable = self.load()
2019-07-18T12:54:14.745048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-18T12:54:14.745050+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-18T12:54:14.745052+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-18T12:54:14.745054+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-18T12:54:14.745056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-18T12:54:14.745058+00:00 app[web.1]: __import__(module)
2019-07-18T12:54:14.745062+00:00 app[web.1]: File "/app/MeryPortfolio-project/MeryPortfolio/wsgi.py", line 16, in <module>
2019-07-18T12:54:14.745064+00:00 app[web.1]: application = get_wsgi_application()
2019-07-18T12:54:14.745067+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-07-18T12:54:14.745069+00:00 app[web.1]: django.setup(set_prefix=False)
2019-07-18T12:54:14.745071+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2019-07-18T12:54:14.745073+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2019-07-18T12:54:14.745076+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
2019-07-18T12:54:14.745077+00:00 app[web.1]: app_config = AppConfig.create(entry)
2019-07-18T12:54:14.745079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
2019-07-18T12:54:14.745081+00:00 app[web.1]: module = import_module(entry)
2019-07-18T12:54:14.745083+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2019-07-18T12:54:14.745085+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-07-18T12:54:14.745087+00:00 app[web.1]: ModuleNotFoundError: No module named 'jobs'
2019-07-18T12:54:14.917101+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-18T12:54:14.897138+00:00 heroku[web.1]: Process exited with status 1
2019-07-18T12:54:15.655426+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=Host.host request_id=d98baa30-b9ee-4835-8b9b-9ef0414036d0 fwd="195.24.36.69" dyno= connect= service= status=503 bytes= protocol=https

Some Python files: MeryPortfolio/urls.py: Jobs could not be 'seen' in that file and it is highlighted in red:

from django.contrib import admin
from django.urls import path, re_path, include
from django.conf import settings
from django.conf.urls.static import static

import jobs.views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', jobs.views.homepage, name='home'),
    #path('jobs/<int:job_id>', jobs.views.detail, name='detail'),
    re_path('^jobs/(?P<job_id>\d+)/$', jobs.views.detail, name="detail"),

]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

MeryPortfolio/settings.py:

import os
import django_heroku

try:
    from . local_settings import *
except ImportError:
    pass

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'xyzxyz...'


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'jobs',

]

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',
]

ROOT_URLCONF = 'MeryPortfolio.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'MeryPortfolio.wsgi.application'

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images) STATICFILES
# https://docs.djangoproject.com/en/2.2/howto/static-files/


STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR

MeryPortfolio/wsgi.py:

"""
WSGI config for MeryPortfolio project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""

import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MeryPortfolio.settings.local")

application = get_wsgi_application()

MeryPortfolio/settings/base.py:

"""
Django base-settings for MeryPortfolio project.

Generated by 'django-admin startproject' using Django 2.2.3.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

try:
    from . local_settings import *
except ImportError:
    pass

MeryPortfolio/settings/local.py:

import os

try:
    from . local_settings import *
except ImportError:
    pass

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.abspath(os.path.join(BASE_DIR, os.pardir)) # as that file should reside in project dir

# Other settings required only for local server like
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'xyzxyz...'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'jobs',

]

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',
]

ROOT_URLCONF = 'MeryPortfolio.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'MeryPortfolio.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql', 
        'NAME': 'dbdb',
        'USER': 'user',
        'PASSWORD': 'xxx',
        'HOST': 'localhost',
        'PORT': 'DDDD'
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L1

0N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'


MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR

MeryPortfolio/settings/production.py

from . import base
import django_heroku
import os

try:
    from . local_settings import *
except ImportError:
    pass

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.abspath(os.path.join(BASE_DIR, os.pardir)) # as that file should reside in project dir

# Other settings required only for live server
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'xyzxyz...'

DEBUG = False

ALLOWED_HOSTS = ['xyz-ddddd.herokuapp.com']

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql', 
        'NAME': 'name',
        'USER': 'user',
        'PASSWORD': 'xyzxyz',
        'HOST': 'host.host',
        'PORT': 'DDDD'
    }
}


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'jobs',


]

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',
]

ROOT_URLCONF = 'MeryPortfolio.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'MeryPortfolio.wsgi.application'

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images) STATICFILES
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'


MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR


# Configure Django App for Heroku.
django_heroku.settings(locals())

Please help to understand where resides the problem with the app opening.

2 Answers 2

1

In Python you can't have a package/module with dashes (-) in it. In that case:

DJANGO_SETTINGS_MODULE=MeryPortfolio-project.MeryPortfolio.settings.production

should not work.

In your tree structure I can't see where jobs app is located and where is your manage.py file. Also you are not telling us how you are starting the WEB server in heroku.

From my knowledge I'm guessing that the structure is as follows:

'MeryPortfolio-project'
    /'MeryPortfolio':
        ...
    /'jobs':
        ...
    'manage.py'

In this case your settings module should be only MeryPortfolio.settings.production. If manage.py is inside MeryPortfolio-project and you are starting the project with manage.py runserver (which is bad for production) it will automatically add MeryPortfolio-project in python path. If you are using gunicorn or something else you need to ensure that MeryPortfolio-project is added to python path

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, your understanding of the structure is correct. Also, I have renamed all directories to replace the uppercases with lowercases and to remove dashes, so MeryPortfolio-project became portfolioproject, MeryPortfolio became meryportfolio, etc So manage.py resides in portfolioproject. The same is for directories jobs and meryportfolio - they are located in portfolioproject. But it gave me the same error when I've done deploy, release and try to open the app. The only thing what I didn't do is to add portfolioproject to Python path. I will try that. Thank you.
Your changes are good and follow PEP8. When you try it please tell us if it is working.
It gave the same errors on Heroku. So I've decided to use DigitalOcean and fortunately, I've succeeded and everything works perfectly there :). Although, I will try to upload to Heroku another Python Django site which I've created, and I will post the results here. Thank everybody for your advice.
0

I could see this error:

2019-07-18T12:54:14.745087+00:00 app[web.1]: ModuleNotFoundError: No module named 'jobs'
2019-07-18T12:54:14.917101+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-18T12:54:14.897138+00:00 heroku[web.1]: Process exited with status 1
2019-07-18T12:54:15.655426+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=Host.host request_id=d98baa30-b9ee-4835-8b9b-9ef0414036d0 fwd="195.24.36.69" dyno= connect= service= status=503

There is 503 Service Unavailable, which means the error is not deploy- related I believe, have you try this code locally, it's most likely is forgotten module export or something like that, I am not a python dev?

1 Comment

Yes, the whole code works Okay locally. But when I've deployed it doesn't work. I suppose it is something related to configs but I couldn't find it yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.