简体   繁体   English

Python Django:您使用的是静态文件应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径

[英]Python Django: You're using the staticfiles app without having set the STATIC_ROOT setting setting to a filesystem path

静态文件 i am trying to deploy my site using heroku but when i run git push heroku master it shows:我正在尝试使用 heroku 部署我的站点,但是当我运行git 推送 heroku master时,它显示:

remote偏僻的

: raise ImproperlyConfigured("You're using the staticfiles app " : raise ImproperlyConfigured("你正在使用静态文件应用程序"

remote偏僻的

: django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. :django.core.exceptions.ImproperlyConfigured:您使用的是静态文件应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径。 remote :远程

remote偏僻的

: . : . Error while running '$ python manage.py collectstatic --noinput'.运行“$ python manage.py collectstatic --noinput”时出错。

settings.py设置.py

import django_heroku
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__)))


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

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


ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'blog.apps.BlogConfig',
    'users.apps.UsersConfig',
    'crispy_forms',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

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 = 'pytalk.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 = 'pytalk.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.1/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.1/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.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, '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_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')

# Activate Django-Heroku.
django_heroku.settings(locals())

You need to give a dir where the statics file can be mounted.您需要提供一个可以挂载静态文件的目录。

https://stackoverflow.com/a/61226365/12691639 https://stackoverflow.com/a/61226365/12691639

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您正在使用 staticfiles 应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径 - You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path 配置不当:您使用的是staticfiles应用,而未将STATIC_ROOT设置设置为文件系统路径 - ImproperlyConfigured:You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path django.core.exceptions.ImproperlyConfigured:您使用的是静态文件应用程序,而没有将 STATIC_ROOT 设置设置为文件系统路径 - django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path Python Django:您正在使用 staticfiles 应用程序,而没有设置 STATIC_ROOT 设置 - Python Django: You're using the staticfiles app without having set the STATIC_ROOT setting Django 中的 STATIC_ROOT 设置 - STATIC_ROOT setting in Django 在 Django 中使用 heroku 时出现 STATIC_ROOT 错误 - Having an Error with STATIC_ROOT when using heroku in Django 使用静态根路径django的heroku deploy错误。 static_root未设置为文件系统路径 - heroku deploy error with static root path django. static_root not set to file system path 在Django中更改STATIC_ROOT和STATICFILES_DIRS后不会加载静态文件 - Static files aren't loading after changing STATIC_ROOT and STATICFILES_DIRS in django Django的。 settings.py-> STATIC_ROOT / STATICFILES_DIRS - Django. settings.py -> STATIC_ROOT/STATICFILES_DIRS 我可以在Django 1.3中使STATICFILES_DIR与STATIC_ROOT相同吗? - Can I make STATICFILES_DIR same as STATIC_ROOT in Django 1.3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM