简体   繁体   English

几天后静态文件不工作

[英]Static Files not working after few days

Static files - bootstrap.min.css and the js files - worked last week and today they are not! 静态文件-bootstrap.min.css和js文件-上周有效,今天却无效! I am using Django 1.11 on Python 3 . 我在Python 3上使用Django 1.11

My static files are stored in - final/static folder. 我的静态文件存储在final/static文件夹中。 Final is the name of my project, ie. Final是我项目的名称,即。 it is stored in the roor 它存储在roor中

settings.py settings.py

import os

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

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

base.html: base.html文件:

<!DOCTYPE html>

{% load staticfiles %}

<html lang="en">
  <head>
    <title>{% block title %}QUIZ{% endblock %}</title>
    <link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
    {% block x_css %}
    {% endblock %}
  </head>

Still, the css and js won't work to give a very plain and undesirable look. 尽管如此,css和js仍无法正常呈现令人讨厌的外观。

STATIC_ROOT designates the directory where the collectstatic management command stores static files. STATIC_ROOT指定collectstatic管理命令用于存储静态文件的目录。 You want the settings: 您需要设置:

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM