0ralo
@0ralo
Нормальный такой питонист + начинаю Android::Java

Django + heroku теряют статику, как исправить?

Короче, второй день пытаюсь развернуть джангу на хероку - постоянно ловлю ошибки. Всё что мог пофиксить - пофиксил.
Проект развернулся, НО, при заходе в админку вижу это
602bebd14c42f600732134.png
В консоли это:
лог
2021-02-16T15:58:41.156157+00:00 app[web.1]: Not Found: /static/admin/css/nav_sidebar.css
2021-02-16T15:58:41.156820+00:00 app[web.1]: 10.29.170.202 - - [16/Feb/2021:15:58:41 +0000] "GET /static/admin/css/nav_sidebar.css HTTP/1.1" 404 2052 "https://testdeploy0.herokuapp.com/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
2021-02-16T15:58:41.158826+00:00 heroku[router]: at=info method=GET path="/static/admin/css/nav_sidebar.css" host=testdeploy0.herokuapp.com request_id=39e04251-6d03-4a8c-b353-4383d74574bf fwd="81.177.127.240" dyno=web.1 connect=1ms service=10ms status=404 bytes=2292 protocol=https
2021-02-16T15:58:41.164782+00:00 app[web.1]: Not Found: /static/admin/css/base.css
2021-02-16T15:58:41.165533+00:00 app[web.1]: 10.95.230.181 - - [16/Feb/2021:15:58:41 +0000] "GET /static/admin/css/base.css HTTP/1.1" 404 2031 "https://testdeploy0.herokuapp.com/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
2021-02-16T15:58:41.166568+00:00 heroku[router]: at=info method=GET path="/static/admin/css/base.css" host=testdeploy0.herokuapp.com request_id=77385739-4e71-423e-9993-b8795ce6280a fwd="81.177.127.240" dyno=web.1 connect=0ms service=16ms status=404 bytes=2271 protocol=https
2021-02-16T15:58:41.312401+00:00 app[web.1]: Not Found: /static/admin/css/login.css
2021-02-16T15:58:41.312844+00:00 app[web.1]: 10.29.170.202 - - [16/Feb/2021:15:58:41 +0000] "GET /static/admin/css/login.css HTTP/1.1" 404 2034 "https://testdeploy0.herokuapp.com/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
2021-02-16T15:58:41.315123+00:00 heroku[router]: at=info method=GET path="/static/admin/css/login.css" host=testdeploy0.herokuapp.com request_id=0327bec3-da00-4119-ab62-982e78aaaa24 fwd="81.177.127.240" dyno=web.1 connect=1ms service=10ms status=404 bytes=2274 protocol=https
2021-02-16T15:58:41.317569+00:00 app[web.1]: Not Found: /static/admin/css/responsive.css
2021-02-16T15:58:41.318249+00:00 app[web.1]: 10.95.230.181 - - [16/Feb/2021:15:58:41 +0000] "GET /static/admin/css/responsive.css HTTP/1.1" 404 2049 "https://testdeploy0.herokuapp.com/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
2021-02-16T15:58:41.319731+00:00 heroku[router]: at=info method=GET path="/static/admin/css/responsive.css" host=testdeploy0.herokuapp.com request_id=63561805-6707-4c66-90c1-72f3b3a2d6f8 fwd="81.177.127.240" dyno=web.1 connect=0ms service=11ms status=404 bytes=2289 protocol=https
2021-02-16T15:58:41.438099+00:00 app[web.1]: Not Found: /static/admin/js/nav_sidebar.js
2021-02-16T15:58:41.438749+00:00 app[web.1]: 10.33.187.161 - - [16/Feb/2021:15:58:41 +0000] "GET /static/admin/js/nav_sidebar.js HTTP/1.1" 404 2046 "https://testdeploy0.herokuapp.com/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"



Получается статика не находится, однако на сервере папка статик создана

602bece257dab764345273.png

Помогите пожалуйста настроить статику((
Если что:
settings.py
"""
Django settings for test_deploy project.

Generated by 'django-admin startproject' using Django 3.1.5.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '!fqclhm(rx0@&5=919soqi(=x^mo4qmwb^_dgikbtc%1h0&iaz'

# 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',
]

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


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/3.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/3.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/3.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
#STATICFILES_DIRS = (
#        BASE_DIR / 'static',
#)


или весь проект:

  • Вопрос задан
  • 45 просмотров
Решения вопроса 2
sergey-gornostaev
@sergey-gornostaev Куратор тега Django
Седой и строгий
azureswastika
@azureswastika
????
Тут все подробно написано.
если будут вопросы, пишите в телеграм
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы