应用程序(Python Django,PostgreSql)已成功部署在Heroku上,但是尝试打开时出现错误

时间:2019-07-18 13:16:19

标签: python django heroku

我已经在Heroku中成功部署了名为MyPortfolio的Python / Django应用。但是,当我尝试打开它时,出现了一个错误: ModuleNotFoundError:没有名为“ jobs”的模块 项目文件夹为“ MeryPortfolio-project”。 项目名称为“ MeryPortfolio”。 应用程序名称为“职位”。 因此Heroku找不到该应用程序的模块。

情况是:我尝试进行本地设置和生产设置。 启动本地服务器时使用的本地设置。 生产设置在Heroku中通过以下命令使用:     heroku config:set DJANGO_SETTINGS_MODULE = MeryPortfolio-project.MeryPortfolio.settings.production 这些目录是: “ MeryPortfolio项目”     /'MeryPortfolio':          _init .py         settings.py         urls.py         wsgi.py         /设置:             初始化 .py             base.py             local.py             production.py

这些是我尝试打开应用程序(heroku打开)时的日志

$ 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

一些Python文件: MeryPortfolio / urls.py: 无法在该文件中“看到”作业,该文件以红色突出显示:

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())

请帮助您了解应用程序打开问题所在的位置。

2 个答案:

答案 0 :(得分:1)

在Python中,您不能包含带有破折号(-)的程序包/模块。在这种情况下:

DJANGO_SETTINGS_MODULE=MeryPortfolio-project.MeryPortfolio.settings.production

不应该工作。

在您的树形结构中,我看不到jobs应用的位置以及您的manage.py文件在哪里。另外,您也没有告诉我们如何在heroku中启动WEB服务器。

据我所知,我猜它的结构如下:

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

在这种情况下,您的设置模块应仅为MeryPortfolio.settings.production。如果manage.pyMeryPortfolio-project内部,并且您以manage.py runserver开始项目(这对生产不利),它将在python路径中自动添加MeryPortfolio-project。如果您使用的是gunicorn或其他方法,则需要确保将MeryPortfolio-project添加到python路径

答案 1 :(得分:0)

我可以看到此错误:

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

有503服务不可用,这意味着该错误与部署无关,我相信,您是否在本地尝试过此代码,很可能是忘记了模块导出或类似的操作,我不是python开发人员?