###困っていること
初心者です。djangogirlsjapanのDeployのところをしているときにネット上でエラーがでました。ほかのところは問題なく出来ました最後のブラウザの読み込みでだめでした 調べた結果、ALLOWED_HOSTSのところにURLを書くみたいなのですが試してもだめでした 他に解決方法があれば教えていただきたいです pythonは3.6.0 djangoは2.0です
###発生している問題・エラーメッセージ
DisallowedHost at / Invalid HTTP_HOST header: '<sample>'. You may need to add '<sample>LLOWED_HOSTS. Request Method: GET Request URL: https://<sample> Django Version: 2.0 Exception Type: DisallowedHost Exception Value: Invalid HTTP_HOST header: '<sample>'. You may need to add '<sample>' to ALLOWED_HOSTS. Exception Location: /app/.heroku/python/lib/python3.6/site-packages/django/http/request.py in get_host, line 105 Python Executable: /app/.heroku/python/bin/python Python Version: 3.6.0
###該当のソースコード
setting.pyのコード """ Django settings for mysite project. Generated by 'django-admin startproject' using Django 2.0. For more information on this file, see https://docs.djangoproject.com/en/2.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os # 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.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'ひみつ' # SECURITY WARNING: don't run with debug turned on in production! ALLOWED_HOSTS = ["<sample>"] ←ここに<アプリ名>.herokuapp.comを入れたがだめ # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', '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 = 'mysite.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 = 'mysite.wsgi.application' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/2.0/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.0/topics/i18n/ LANGUAGE_CODE = 'ja' TIME_ZONE = 'Asia/Tokyo' USE_I18N = True USE_L10N = True USE_TZ = False #defaultではUTCのタイムゾーンのためFalseに変更 # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.0/howto/static-files/ STATIC_URL = '/static/' import dj_database_url DATABASES["default"] = dj_database_url.config() SECURE_HOSTS = ["*"] STATIC_ROOT = "staticfiles" DEBUG = False try: from .local_settings import * except ImportError: pass
###試したこと
https://qiita.com/esehara@github/items/27c0d1f76bea8ac9169e
などの記事をためした
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
回答1件
あなたの回答
tips
プレビュー