状況
djangoのアプリをherokuにデプロイして、migrateしようとしたらerrorが出ました。
発生している問題・エラーメッセージ
$heroku run python3 manage.py migrate ModuleNotFoundError: No module named 'accounts'
setting.py
python
1import os 2import dj_database_url 3# Build paths inside the project like this: os.path.join(BASE_DIR, ...) 4from pathlib import Path 5BASE_DIR = Path(__file__).resolve().parent.parent 6 7 8SECRET_KEY = os.environ['SECRET_KEY'] 9import django_heroku 10 11# Quick-start development settings - unsuitable for production 12# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ 13 14# SECURITY WARNING: keep the secret key used in production secret! 15 16STATIC_URL = '/static/' 17 18# SECURITY WARNING: don't run with debug turned on in production! 19DEBUG = False 20 21ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com'] 22 23# Application definition 24 25INSTALLED_APPS = [ 26 'sample.apps.SampleConfig', 27 'accounts.apps.AccountsConfig', 28 29 'rest_framework', 30 31 'django.contrib.admin', 32 'django.contrib.auth', 33 'django.contrib.contenttypes', 34 'django.contrib.sessions', 35 'django.contrib.messages', 36 'django.contrib.staticfiles', 37 38] 39 40MIDDLEWARE = [ 41 'django.middleware.security.SecurityMiddleware', 42 'django.contrib.sessions.middleware.SessionMiddleware', 43 'django.middleware.common.CommonMiddleware', 44 'django.middleware.csrf.CsrfViewMiddleware', 45 'django.contrib.auth.middleware.AuthenticationMiddleware', 46 'django.contrib.messages.middleware.MessageMiddleware', 47 'django.middleware.clickjacking.XFrameOptionsMiddleware', 48 'whitenoise.middleware.WhiteNoiseMiddleware', 49] 50 51ROOT_URLCONF = 'app_config.urls' 52 53TEMPLATES = [ 54 { 55 'BACKEND': 'django.template.backends.django.DjangoTemplates', 56 'DIRS': [os.path.join(BASE_DIR, 'templates')], 57 'APP_DIRS': True, 58 'OPTIONS': { 59 'context_processors': [ 60 'django.template.context_processors.debug', 61 'django.template.context_processors.request', 62 'django.contrib.auth.context_processors.auth', 63 'django.contrib.messages.context_processors.messages', 64 ], 65 }, 66 }, 67] 68 69WSGI_APPLICATION = 'app_config.wsgi.application' 70 71 72# Database 73# https://docs.djangoproject.com/en/2.1/ref/settings/#databases 74###########12 17 75STATICFILES_DIRS = ( 76 [os.path.join(BASE_DIR, 'static')] 77) 78 79AUTH_USER_MODEL = "accounts.CustomUser" 80######### 81 82# Password validation 83# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators 84 85AUTH_PASSWORD_VALIDATORS = [ 86 { 87 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 88 }, 89 { 90 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 91 }, 92 { 93 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 94 }, 95 { 96 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 97 }, 98] 99 100 101# Internationalization 102# https://docs.djangoproject.com/en/2.1/topics/i18n/ 103 104LANGUAGE_CODE = 'ja' 105 106TIME_ZONE = 'Asia/Tokyo' 107 108USE_I18N = True 109 110USE_L10N = True 111 112USE_TZ = True 113 114 115# Static files (CSS, JavaScript, Images) 116# https://docs.djangoproject.com/en/2.1/howto/static-files/ 117 118STATIC_URL = '/static/' 119 120 121DATABASES = { 122 'default': { 123 'ENGINE': 'django.db.backends.postgresql_psycopg2', 124 'NAME': 'xxxxxxxxxx', 125 'USER': 'xxxxxxxx', 126 'PASSWORD': 'xxxxxxxx', 127 'HOST': 'xxxxxxxxx', 128 'PORT': '', 129 }, 130 'OPTIONS': { 131 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", 132 }, 133} 134 135################## 136if not DEBUG: 137 SECRET_KEY = os.environ['SECRET_KEY'] 138 139 140db_from_env = dj_database_url.config(conn_max_age=600, ssl_require=True) 141DATABASES['default'].update(db_from_env) 142 143 144django_heroku.settings(locals()) #追加
教えて下さい。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/12/18 08:58