Django некоторые css не работают в продакшене

I have a django app. In production I ran collectstatic and all good except a small piece of css. This css thing is a question mark which on hover shows some tips about the app feature. This also could be a nginx configuration issue maybe. But again, just this piece of css does not work properly.

html

<div class="help-tip">
 <p> 
    some text
 </p>
</div>                               

css

/*-------------------------
    Inline help tip
--------------------------*/
.help-tip-wrapper{
  padding-top: 15px;
  padding-left: 5px;
}

.help-tip{
    text-align: center;
    background-color: #BCDBEA;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    line-height: 26px;
    cursor: default;
}

.help-tip:before{
    content:'?';
    font-weight: bold;
    color:#fff;
}

.help-tip:hover p{
    display:block;

    -webkit-animation: fadeIn 0.3s ease-in-out;
    animation: fadeIn 0.3s ease-in-out;

}

.help-tip p{
    display: none;
    background-color: #1E2021;
    padding: 20px;
    width: 300px;
    border-radius: 3px;
    right: -4px;
    color: #FFF;
  font-weight: normal;
    font-size: 10px;
  z-index: 100;
    line-height: 1.4;
  position: relative;
}

.help-tip p:before{
    content: '';
    width:0;
    height: 0;
    border:6px solid transparent;
    border-bottom-color:#1E2021;
    right:10px;
    top:-12px;
}

.help-tip p:after{
    width:100%;
    height:40px;
    content:'';
    top:-40px;
    left:0;
}

settings.py

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

Все css работают нормально, кроме этого.

Ваш settings.py файл неправильный.

Это должно выглядеть следующим образом

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATIC_DIRS = [
     os.path.join(BASE_DIR, 'static')
]

Также вы должны обновить ваш nginx или apach2 сервер с вышеуказанными изменениями 'staticfiles'

Когда вы выполните команду collectstatic, она сохранит ваш пакет в папке staticfiles и он будет обслуживаться, когда вы выполните команду DEBUG=False . Если ваш debug=True, то он будет обслуживаться из папки static

Вы не использовали отображение url для "collectstatic". Поэтому в настройках используйте такое отображение. (можно редактировать по своему усмотрению, кроме ключевого слова (изменяемое имя))

STATIC_URL = '/static/'
STATICFILES_DIRS=[BASE_DIR / 'static']
STATIC_ROOT= BASE_DIR / 'staticfiles'

После этого запустите 'collectstatic'. Вы получите все css в этом продакшене, в этом конкретном url mapped файле .

Вернуться на верх