未在开发中显示文件

问题描述 投票:0回答:1

用户个人资料图片可以在https://rossdjangoawesomeapp2.herokuapp.com/上很好地加载,但是当我使用http://localhost:8000/时,它们都没有加载。我认为该错误可能是在我将站点配置为与AWS一起使用时开始的。我现在的困难是我真的不知道从哪里开始寻找有关如何解决此问题的建议。

Settings.py

import os
import django_heroku


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))



SECRET_KEY = os.environ.get('SECRET_KEY')

DEBUG = (os.environ.get('DEBUG_VALUE')=='True')

ALLOWED_HOSTS = ['rossdjangoawesomeapp.herokuapp.com']


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}




STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGIN_REDIRECT_URL = 'blog-home'
LOGIN_URL = 'login'

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD =  os.environ.get('EMAIL_PASS')
EMAIL_PORT = 587

AUTHENTICATION_BACKENDS = (
    #Needed to login by username in Django admin, regardless of 'allauth'
    'django.contrib.auth.backends.ModelBackend',

    #allauth specifc authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
    )

CRISPY_TEMPLATE_PACK = 'bootstrap4'

AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')




AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

django_heroku.settings(locals())
python
1个回答
0
投票

尝试将本地URL 127.0.0.1:8000 / localhost:8000添加到允许的主机中

ALLOWED_HOSTS = ['rossdjangoawesomeapp.herokuapp.com', 'localhost', '127.0.0.1']
热门问题
推荐问题
最新问题